package com.dragon.mmochat.service;

import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.message.Mmochat_14_12C;
import com.dragon.mmochat.message.Mmochat_14_12S;
import com.dragon.mmochat.message.Mmochat_14_13C;
import com.dragon.mmochat.message.Mmochat_5_10S;
import com.dragon.mmochat.message.Mmochat_5_1S;
import com.dragon.mmochat.model.attackMode.MmochatAttackModeOfNormal;
import com.dragon.mmochat.model.enumType.MmochatBossLevelType;
import com.dragon.mmochat.model.enumType.MmochatEquipAttributeQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipAttributeType;
import com.dragon.mmochat.model.enumType.MmochatEquipGiftType;
import com.dragon.mmochat.model.enumType.MmochatEquipQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipType;
import com.dragon.mmochat.model.enumType.MmochatEquipVersion;
import com.dragon.mmochat.model.enumType.MmochatMaterialType;
import com.dragon.mmochat.model.enumType.MmochatNpcItemType;
import com.dragon.mmochat.model.enumType.MmochatObjOwnerState;
import com.dragon.mmochat.model.enumType.MmochatObjectType;
import com.dragon.mmochat.model.enumType.MmochatPropType;
import com.dragon.mmochat.model.enumType.MmochatRoleBmpType;
import com.dragon.mmochat.model.enumType.MmochatRoleStateType;
import com.dragon.mmochat.model.enumType.MmochatSecondRoleType;
import com.dragon.mmochat.model.enumType.MmochatSmallMoneyCostType;
import com.dragon.mmochat.model.enumType.MmochatSuperMachineType;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatEquip;
import com.dragon.mmochat.model.object.MmochatEquipAttribute;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.dragon.mmochat.model.object.MmochatProp;
import com.dragon.mmochat.model.role.MmochatMonster;
import com.dragon.mmochat.model.role.MmochatMonsterFactory;
import com.dragon.mmochat.model.role.MmochatPet;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.dragon.mmochat.util.MmochatUtil;
import com.google.gson.reflect.TypeToken;
import com.skymobi.handler.SkymobiHandler;
import com.skymobi.message.SkymobiProtocolMessage;
import com.skymobi.message.widget.AddDataTLV;
import com.skymobi.message.widget.CreateMsgBoxTLV;
import com.skymobi.message.widget.SendDataTLV;
import com.skymobi.message.widget.ShowWaitingMsgBoxTLV;
import com.skymobi.service.SkymobiService;
import com.skymobi.util.Text;

public class MmochatEquipService {
	private static Logger log = LoggerFactory
			.getLogger(MmochatEquipService.class);

	public static ScheduledExecutorService checkOwnerThread = Executors
			.newScheduledThreadPool(1);

	// 装备基础属性：Map<装备类别, Map<基础属性类别, Map<Level, Value>>>
	private static Map<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer>>> equipBaseAttrData = new ConcurrentHashMap<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer>>>();

	// 装备改造数值：Map<装备类别, Map<基础属性类别, Map<Level, Map<打造级别, Value>>>>
	private static Map<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Map<Integer, Integer>>>> equipModifyAttrData = new ConcurrentHashMap<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Map<Integer, Integer>>>>();

	// 装备随机属性：Map<装备类别,Map<随机属性类别, Map<Level, Integer[最小/最大]>>>
	public static Map<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>> equipRandAttrData = new ConcurrentHashMap<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>>();

	// 套装明属性：Map<装备类别,Map<随机属性类别, Map<Level, Integer[最小/最大]>>>
	private static Map<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>> greenEquipLightAttrData = new ConcurrentHashMap<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>>();

	// 套装暗属性：Map<装备类别,Map<随机属性类别, Map<Level, Integer[最小/最大]>>>
	private static Map<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>> greenEquipDarkAttrData = new ConcurrentHashMap<MmochatEquipType, Map<MmochatEquipAttributeType, Map<Integer, Integer[]>>>();

	// Map<装备类别,Map<Level, 回收价格>>
	private static Map<MmochatEquipType, Map<Integer, Integer>> equipRecyclePrice = new ConcurrentHashMap<MmochatEquipType, Map<Integer, Integer>>();

	// 改造机率
	public static int modifyRate[] = new int[] { 90, 80, 70, 60, 50, 40, 30,
			20, 15, 10, 9, 9, 8, 8, 7, 7, 6, 6, 6, 6 };

	// 白水晶抽取属性机率
	public static int separateEquipAttrRate = 50;

	// 粉水晶粉化成功机率
	public static int pinkEquipAttrRate = 99;

	// 绿水晶绿化成功机率
	public static int greenEquipAttrRate = 99;

	// 强化属性成功机率(判定成功后，尝试生成新数值，不保证新数值高于原数值)
	public static int strenthenEquipAttrRate = 99;

	// 装备升级成功机率
	public static int equipUplevelRate[] = new int[] { 100, 98, 95, 90, 85, 80,
			75, 70, 65, 60 };

	// 武魂石等级上限所需突破石,前36个数字有效,
	// pkStoneUplevelNum[当前等级],表示当前等级升到下一级要的突破石数量
	public static int pkStoneUplevelNum[] = new int[] { 0, 0, 0, 0, 0, 0, 2, 2,
			2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 10, 10, 10,
			10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
			12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
			12, 12, 12, 12, 12, 12 };

	public MmochatEquipService() {
		if (!MmochatMain.openMergeServer) {
			/************** 装备装备基础属性 **************/
			log.debug("开始加载装备属性数据");
			equipBaseAttrData.clear();
			equipBaseAttrData.put(MmochatEquipType.武器,
					parseEquipBaseAttrMapFromFile("equip/weapon/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.头盔,
					parseEquipBaseAttrMapFromFile("equip/head/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.衣服,
					parseEquipBaseAttrMapFromFile("equip/cloth/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.鞋子,
					parseEquipBaseAttrMapFromFile("equip/shoe/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.挂坠,
					parseEquipBaseAttrMapFromFile("equip/guaZhui/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.玉佩,
					parseEquipBaseAttrMapFromFile("equip/yuPei/baseAttr"));
			equipBaseAttrData.put(MmochatEquipType.手镯,
					parseEquipBaseAttrMapFromFile("equip/shouZhuo/baseAttr"));

			/************** 装载改造属性 **************/
			equipModifyAttrData.clear();
			equipModifyAttrData.put(MmochatEquipType.武器,
					parseEquipModifyAttrMapFromFile("equip/weapon/modifyAttr"));
			equipModifyAttrData.put(MmochatEquipType.头盔,
					parseEquipModifyAttrMapFromFile("equip/head/modifyAttr"));
			equipModifyAttrData.put(MmochatEquipType.衣服,
					parseEquipModifyAttrMapFromFile("equip/cloth/modifyAttr"));
			equipModifyAttrData.put(MmochatEquipType.鞋子,
					parseEquipModifyAttrMapFromFile("equip/shoe/modifyAttr"));

			/************** 装载装备随机属性 **************/
			equipRandAttrData.clear();
			equipRandAttrData.put(MmochatEquipType.武器,
					parseEquipRandAttrMapFromFile("equip/weapon/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.头盔,
					parseEquipRandAttrMapFromFile("equip/head/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.衣服,
					parseEquipRandAttrMapFromFile("equip/cloth/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.鞋子,
					parseEquipRandAttrMapFromFile("equip/shoe/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.挂坠,
					parseEquipRandAttrMapFromFile("equip/guaZhui/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.玉佩,
					parseEquipRandAttrMapFromFile("equip/yuPei/extraAttr"));
			equipRandAttrData.put(MmochatEquipType.手镯,
					parseEquipRandAttrMapFromFile("equip/shouZhuo/extraAttr"));

			/************** 装载套装明属性 **************/
			greenEquipLightAttrData.clear();
			greenEquipLightAttrData.put(MmochatEquipType.武器,
					parseEquipRandAttrMapFromFile("equip/weapon/lightSetAttr"));
			greenEquipLightAttrData.put(MmochatEquipType.头盔,
					parseEquipRandAttrMapFromFile("equip/head/lightSetAttr"));
			greenEquipLightAttrData.put(MmochatEquipType.衣服,
					parseEquipRandAttrMapFromFile("equip/cloth/lightSetAttr"));
			greenEquipLightAttrData.put(MmochatEquipType.鞋子,
					parseEquipRandAttrMapFromFile("equip/shoe/lightSetAttr"));

			/************** 装载套装暗属性 **************/
			greenEquipDarkAttrData.clear();
			greenEquipDarkAttrData.put(MmochatEquipType.武器,
					parseEquipRandAttrMapFromFile("equip/weapon/darkSetAttr"));
			greenEquipDarkAttrData.put(MmochatEquipType.头盔,
					parseEquipRandAttrMapFromFile("equip/head/darkSetAttr"));
			greenEquipDarkAttrData.put(MmochatEquipType.衣服,
					parseEquipRandAttrMapFromFile("equip/cloth/darkSetAttr"));
			greenEquipDarkAttrData.put(MmochatEquipType.鞋子,
					parseEquipRandAttrMapFromFile("equip/shoe/darkSetAttr"));

			/************** 装载装备价格 **************/
			log.debug("loading equip recycle price...");
			equipRecyclePrice.clear();
			File file = new File("equip/equipPrice.txt");
			if (file.exists() && file.isFile()) {
				try {
					BufferedReader reader;
					reader = new BufferedReader(new FileReader(file));
					String lineBuf;
					int level = 0;
					Map<Integer, Integer> lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.头盔, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.手镯, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.挂坠, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.武器, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.玉佩, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.衣服, lineMap);
					lineMap = new ConcurrentHashMap<Integer, Integer>();
					equipRecyclePrice.put(MmochatEquipType.鞋子, lineMap);

					reader.readLine();
					while ((lineBuf = reader.readLine()) != null) {
						if (lineBuf.trim().length() == 0) {
							continue;
						}
						String[] array = lineBuf.split("\t");
						if (array != null && array.length > 0) {
							int[] values = new int[array.length];
							for (int i = 0; i < array.length; i++) {
								try {
									values[i] = Integer.parseInt(array[i]);
								} catch (NumberFormatException e) {
									e.printStackTrace();
									throw new RuntimeException(
											"equip/装备价格.txt 中包含非数字价格!");
								}
							}
							level = values[0];
							Map<Integer, Integer> dataMap = equipRecyclePrice
									.get(MmochatEquipType.武器);
							dataMap.put(level, values[1]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.手镯);
							dataMap.put(level, values[2]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.挂坠);
							dataMap.put(level, values[3]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.玉佩);
							dataMap.put(level, values[4]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.衣服);
							dataMap.put(level, values[5]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.头盔);
							dataMap.put(level, values[6]);
							dataMap = equipRecyclePrice
									.get(MmochatEquipType.鞋子);
							dataMap.put(level, values[7]);
						}
					}
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} else {
				throw new RuntimeException("equip/装备价格.txt 文件缺失!");
			}
			log.debug("equip recycle price is loaded!");

			checkOwnerThread.scheduleWithFixedDelay(new checkOwnerState(), 1,
					1, TimeUnit.MINUTES);
		}
	}

	public static void updateOwnerStateForPlayer(MmochatPlayer me) {
		if (me != null) {
			// 检查仓库、包裹中的装备、法宝、宠物的认主状态

			// 包裹中的装备、法宝
			List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
			for (MmochatPackageGrid grid : me.getMyPackage().values()) {
				if (grid != null) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOwnerState() == MmochatObjOwnerState.解除认主中) {
							if (System.currentTimeMillis()
									- obj.getReleaseOwnerStartTime() > MmochatConstant.releaseOwnerInterval) {
								// 解除认主
								obj.setOwnerState(MmochatObjOwnerState.未认主);
								gridNeedUpdate.add(grid);
							}
						}
					}
				}
			}
			if (gridNeedUpdate.size() > 0) {
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			// 仓库中的装备法宝
			boolean needUpdate = false;
			for (MmochatPackageGrid grid : me.getMyStorage().values()) {
				if (grid != null) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOwnerState() == MmochatObjOwnerState.解除认主中) {
							if (System.currentTimeMillis()
									- obj.getReleaseOwnerStartTime() > MmochatConstant.releaseOwnerInterval) {
								// 解除认主
								obj.setOwnerState(MmochatObjOwnerState.未认主);
								needUpdate = true;
							}
						}
					}
				}
			}
			if (needUpdate) {
				try {
					MmochatDao.updateMyStorage(me);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			// 身上带的宠
			Mmochat_5_10S pack = new Mmochat_5_10S();
			for (MmochatPet pet : me.getPets().values()) {
				if (pet != null) {
					if (pet.getOwnerState() == MmochatObjOwnerState.解除认主中) {
						if (System.currentTimeMillis()
								- pet.getReleaseOwnerStartTime() > MmochatConstant.releaseOwnerInterval) {
							// 解除认主
							pet.setOwnerState(MmochatObjOwnerState.未认主);
							pack.addPet(pet);
						}
					}
				}
			}
			if (pack.hasPet()) {
				MmochatUtil.sendCommonPack(me, pack);
				try {
					MmochatDao.updateRolePets(me);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			// 仓库的宠
			needUpdate = false;
			for (MmochatPet pet : me.getStoredPets().values()) {
				if (pet != null) {
					if (pet.getOwnerState() == MmochatObjOwnerState.解除认主中) {
						if (System.currentTimeMillis()
								- pet.getReleaseOwnerStartTime() > MmochatConstant.releaseOwnerInterval) {
							// 解除认主
							pet.setOwnerState(MmochatObjOwnerState.未认主);
							needUpdate = true;
						}
					}
				}
			}
			if (needUpdate) {
				try {
					MmochatDao.updateStorePet(me);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

	}

	public static void checkOwnerStateForPlayer(MmochatPlayer me) {
		if (me != null) {
			// 检查仓库、包裹中的装备、法宝、宠物的认主状态
			int packageEquipNum = 0;
			int storageEquipNum = 0;
			int petNum = 0;
			int storagePetNum = 0;
			for (MmochatPackageGrid grid : me.getMyPackage().values()) {
				if (grid != null) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOwnerState() == MmochatObjOwnerState.解除认主中) {
							packageEquipNum++;
						}
					}
				}
			}

			// 仓库中的装备法宝
			for (MmochatPackageGrid grid : me.getMyStorage().values()) {
				if (grid != null) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOwnerState() == MmochatObjOwnerState.解除认主中) {
							storageEquipNum++;
						}
					}
				}
			}

			// 身上带的宠
			for (MmochatPet pet : me.getPets().values()) {
				if (pet != null) {
					if (pet.getOwnerState() == MmochatObjOwnerState.解除认主中) {
						petNum++;
					}
				}
			}

			// 仓库的宠
			for (MmochatPet pet : me.getStoredPets().values()) {
				if (pet != null) {
					if (pet.getOwnerState() == MmochatObjOwnerState.解除认主中) {
						storagePetNum++;
					}
				}
			}
			String hint = "";
			if (packageEquipNum > 0) {
				hint += "包裹中有"
						+ MmochatUtil.wrapColor(packageEquipNum + "个物品",
								Color.green) + "正在"
						+ MmochatUtil.wrapColor("解除认主中", Color.yellow) + ",";
			}
			if (storageEquipNum > 0) {
				hint += "仓库中有"
						+ MmochatUtil.wrapColor(storageEquipNum + "个物品",
								Color.green) + "正在"
						+ MmochatUtil.wrapColor("解除认主中", Color.yellow) + ",";
			}
			if (petNum > 0) {
				hint += "身上携带的宠物中有"
						+ MmochatUtil.wrapColor(petNum + "个宠物", Color.green)
						+ "正在" + MmochatUtil.wrapColor("解除认主中", Color.yellow)
						+ ",";
			}
			if (storagePetNum > 0) {
				hint += "仓库中有"
						+ MmochatUtil.wrapColor(storagePetNum + "个宠物",
								Color.green) + "正在"
						+ MmochatUtil.wrapColor("解除认主中", Color.yellow) + ",";
			}
			if (hint.length() > 0) {
				hint = "您的" + hint + "请确认是否是您自己执行的!";
				MmochatChatService.sendSystemMsgToPerson(me, hint);
			}
		}

	}

	// 检查认主状态
	class checkOwnerState implements Runnable {
		@Override
		public void run() {
			try {
				for (MmochatPlayer me : MmochatMainService.players.values()) {
					try {
						updateOwnerStateForPlayer(me);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static Map<MmochatEquipAttributeType, Map<Integer, Map<Integer, Integer>>> parseEquipModifyAttrMapFromFile(
			String folderPath) {
		Map<MmochatEquipAttributeType, Map<Integer, Map<Integer, Integer>>> modifyAttr = new ConcurrentHashMap<MmochatEquipAttributeType, Map<Integer, Map<Integer, Integer>>>();
		File root;
		File[] files;
		Pattern fileNamePattern = Pattern.compile("[^/]*\\.");
		root = new File(folderPath);
		files = root.listFiles();
		if (files != null) {
			for (File file : files) {
				if (!file.isFile()) {
					continue;
				}
				String fileName = file.getName();
				Matcher matcher = fileNamePattern.matcher(fileName);
				if (matcher.find()) {
					String fileStr = matcher.group();
					fileStr = fileStr.substring(0, fileStr.length() - 1);
					log.debug("属性名：" + fileStr);
					MmochatEquipAttributeType attrType = MmochatEquipAttributeType
							.getEquipAttributeTypeByShortName(fileStr);
					if (attrType == null) {
						throw new RuntimeException(folderPath + "," + fileStr
								+ "：没有对应的属性类型");
					}
					modifyAttr
							.put(attrType, parseEquipModifyAttrFromFile(file));
				}
			}
		}
		return modifyAttr;
	}

	public static Map<MmochatEquipAttributeType, Map<Integer, Integer[]>> parseEquipRandAttrMapFromFile(
			String folderPath) {
		Map<MmochatEquipAttributeType, Map<Integer, Integer[]>> randAttr = new ConcurrentHashMap<MmochatEquipAttributeType, Map<Integer, Integer[]>>();
		File root;
		File[] files;
		Pattern fileNamePattern = Pattern.compile("[^/]*\\.");
		root = new File(folderPath);
		files = root.listFiles();
		if (files != null) {
			for (File file : files) {
				if (!file.isFile()) {
					continue;
				}
				String fileName = file.getName();
				Matcher matcher = fileNamePattern.matcher(fileName);
				if (matcher.find()) {
					String fileStr = matcher.group();
					fileStr = fileStr.substring(0, fileStr.length() - 1);
					log.debug("属性名：" + fileStr);
					MmochatEquipAttributeType attrType = MmochatEquipAttributeType
							.getEquipAttributeTypeByShortName(fileStr);
					if (attrType == null) {
						throw new RuntimeException(folderPath + "," + fileStr
								+ "：没有对应的属性类型");
					}
					randAttr.put(attrType, parseEquipRandAttrFromFile(file));
				}
			}
		}
		return randAttr;
	}

	public static Map<MmochatEquipAttributeType, Map<Integer, Integer>> parseEquipBaseAttrMapFromFile(
			String folderPath) {
		Map<MmochatEquipAttributeType, Map<Integer, Integer>> baseAttr = new ConcurrentHashMap<MmochatEquipAttributeType, Map<Integer, Integer>>();
		File root;
		File[] files;
		Pattern fileNamePattern = Pattern.compile("[^/]*\\.");
		root = new File(folderPath);
		files = root.listFiles();
		if (files != null) {
			for (File file : files) {
				if (!file.isFile()) {
					continue;
				}
				String fileName = file.getName();
				Matcher matcher = fileNamePattern.matcher(fileName);
				if (matcher.find()) {
					String fileStr = matcher.group();
					fileStr = fileStr.substring(0, fileStr.length() - 1);
					log.debug("属性名：" + fileStr);
					MmochatEquipAttributeType attrType = MmochatEquipAttributeType
							.getEquipAttributeTypeByShortName(fileStr);
					if (attrType == null) {
						throw new RuntimeException(folderPath + "," + fileStr
								+ "：没有对应的属性类型");
					}
					baseAttr.put(attrType, parseEquipBaseAttrFromFile(file));
				}
			}
		}
		return baseAttr;
	}

	// 解析一个装备基础属性文件
	private static Map<Integer, Integer> parseEquipBaseAttrFromFile(File file) {
		Map<Integer, Integer> map = new ConcurrentHashMap<Integer, Integer>();
		if (file.exists()) {
			if (file.isFile()) {
				try {
					BufferedReader reader = new BufferedReader(new FileReader(
							file));
					String lineBuf;
					int level = 0;
					while ((lineBuf = reader.readLine()) != null) {
						if (lineBuf.trim() == "") {
							continue;
						}
						try {
							int value = Integer.parseInt(lineBuf.trim());
							map.put(level, value);
						} catch (NumberFormatException e) {
							e.printStackTrace();
							throw new RuntimeException("装备配置文件有非数字!文件名:"
									+ file.getName());
						}
						level += 10;
					}
					log.debug(file.getName() + "\t装载了" + level / 10
							+ "个等级的装备基础属性");
				} catch (FileNotFoundException e) {
					e.printStackTrace();
					throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
				} catch (IOException e) {
					e.printStackTrace();
					throw new RuntimeException("装备配置读取出错!文件名:" + file.getName());
				}
			} else {
				throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
			}
		} else {
			throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
		}
		return map;
	}

	// 解析一个装备改造属性文件
	private static Map<Integer, Map<Integer, Integer>> parseEquipModifyAttrFromFile(
			File file) {
		Map<Integer, Map<Integer, Integer>> map = new ConcurrentHashMap<Integer, Map<Integer, Integer>>();
		if (file.exists()) {
			if (file.isFile()) {
				try {
					BufferedReader reader = new BufferedReader(new FileReader(
							file));
					String lineBuf;
					int level = 0;
					while ((lineBuf = reader.readLine()) != null) {
						String[] array = lineBuf.split("\t");
						if (array != null && array.length > 0) {
							Map<Integer, Integer> lineMap = new ConcurrentHashMap<Integer, Integer>();
							if (array.length != MmochatConstant.maxEquipModifyLevel) {
								throw new RuntimeException("锻造等级数不匹配!文件名:"
										+ file.getName());
							}
							for (int madeLevel = 0; madeLevel < array.length; madeLevel++) {
								if (array[madeLevel].trim() == "") {
									continue;
								}
								try {
									int value = Integer
											.parseInt(array[madeLevel].trim());
									lineMap.put(madeLevel, value);
								} catch (NumberFormatException e) {
									e.printStackTrace();
									throw new RuntimeException(
											"装备配置文件有非数字!文件名:" + file.getName());
								}
							}
							if (lineMap.size() > 0) {
								map.put(level, lineMap);
							}
						}
						level += 10;
					}
					log.debug(file.getName() + "\t装载了" + level / 10
							+ "个等级的装备改造属性");
				} catch (FileNotFoundException e) {
					e.printStackTrace();
					throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
				} catch (IOException e) {
					e.printStackTrace();
					throw new RuntimeException("装备配置读取出错!文件名:" + file.getName());
				}
			} else {
				throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
			}
		} else {
			throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
		}
		return map;
	}

	// 解析一个装备的随机属性
	private static Map<Integer, Integer[]> parseEquipRandAttrFromFile(File file) {
		if (file == null || !file.isFile()) {
			throw new RuntimeException("装备随机属性文件缺失");
		}
		Map<Integer, Integer[]> map = new ConcurrentHashMap<Integer, Integer[]>();
		try {
			BufferedReader reader = new BufferedReader(new FileReader(file));
			String lineBuf;
			int level = 0;
			while ((lineBuf = reader.readLine()) != null) {
				String[] array = lineBuf.split("\t");
				if (array != null && array.length > 0) {
					if (array.length < 2) {
						throw new RuntimeException("装备配置文件至少要两个数字!文件名:"
								+ file.getName());
					}

					Integer[] v = new Integer[2];
					try {
						int min = Integer.parseInt(array[0].trim());
						v[0] = min;
						int max = Integer.parseInt(array[1].trim());
						v[1] = max;
					} catch (NumberFormatException e) {
						e.printStackTrace();
						throw new RuntimeException("装备配置文件有非数字!文件名:"
								+ file.getName());
					}
					map.put(level, v);
				}
				level += 10;
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			throw new RuntimeException("装备配置文件缺失!文件名:" + file.getName());
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException("装备配置读取出错!文件名:" + file.getName());
		}
		return map;
	}

	// 获取NPC出售的普通武器售价
	public static int getEquipPrice(MmochatEquipType type, int level) {
		Map<Integer, Integer> dataMap = equipRecyclePrice.get(type);
		if (dataMap == null) {
			return 999999;
		}
		Integer price = dataMap.get(level);
		if (price == null) {
			return 999999;
		}
		return price;
	}

	// 获取装备回收价格
	public static int getEquipSellToSystemPrice(MmochatCommonObject equip) {
		if (equip.getEquipLevelNeed() < 10) {
			// 0级装备回收价为0
			return 1;
		}
		int basePrice = getEquipPrice(equip.getEquipType(), equip
				.getEquipLevelNeed());

		switch (equip.getEquipQuality()) {
		case 白装:
			return (int) (basePrice * 0.8);
		default:
			int attrNum = equip.getEquipRandAttr().size();
			return 3 * basePrice * attrNum;
		}
	}

	// 获取装备改造价格
	public static int getEquipModifyPrice(MmochatCommonObject equip) {
		if (equip == null) {
			return 999999;
		}
		return (equip.getEquipModifyLevel() + 1)
				* getEquipPrice(equip.getEquipType(), equip.getEquipLevelNeed());
	}

	// 获取特定等级装备的基础属性值
	public static int getEquipBaseAttrValue(MmochatEquipType type, int level,
			MmochatEquipAttributeType attr) {
		level = level / 10 * 10;
		if (level <= 0) {
			level = 0;
		}
		int value = 0;
		try {
			value = equipBaseAttrData.get(type).get(attr).get(level);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}

	// 获取特定等级装备的改造属性数值
	public static int getEquipModifyValue(MmochatEquipType type, int level,
			MmochatEquipAttributeType attr, int modifyLevel) {
		if (modifyLevel <= 0) {
			return 0;
		}
		level = level / 10 * 10;
		if (level <= 0) {
			level = 0;
		}
		int value = 0;
		try {
			value = equipModifyAttrData.get(type).get(attr).get(level).get(
					modifyLevel - 1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}

	// 获取武器名
	public static String getEquipName(MmochatEquipType type, int level) {
		String[] weaponNames = new String[] { "阴阳剑", "二龙剑", "青云剑", "飞烟剑",
				"指尘剑", "腾空剑", "血目剑", "巨阙剑", "青萍剑", "逸龙剑", "轩辕剑", "娲皇剑", "诛仙剑" };
		String[] headNames = new String[] { "五行盔", "金霞冠", "指天帽", "云烟冠", "太乙木冠",
				"九天玄盔", "九焰冠", "冲天盔", "星耀冠", "蚩尤盔", "轩辕冠", "娲女冠", "乾坤冠" };
		String[] clothNames = new String[] { "五行法衣", "扫霞衣", "昊天云衣", "七皂罗衫",
				"净尘衫", "九天玄甲", "南明离火服", "洪荒龟甲", "八卦紫绶衣", "蚩尤魔甲", "黄帝袍", "红彤羽衣",
				"紫绶仙衣" };
		String[] shoeNames = new String[] { "五光鞋", "五色履", "追云靴", "七皂罗靴", "疾风靴",
				"空明玄足", "风火轮", "逐日靴", "紫绶鞋", "冥河支腿", "混元靴", "无影鞋", "云蛟履" };
		String[] yuNames = new String[] { "五行玉", "紫霞宝玉", "七香坠", "玲珑七窍心", "无垢坠",
				"和氏璧", "颜如玉", "盘天坠", "龙虎如意", "乱心尘", "九州龙鼎玉玺", "彼女坠", "三宝玉如意" };
		String[] zhuiNames = new String[] { "戳目珠", "定海珠", "定风珠", "日月珠", "劈地珠",
				"红珠", "乾天火灵珠", "一元珠", "霹雳雷火珠", "凝血神珠", "混元宝珠", "开天珠", "乾坤珠" };
		String[] shouNames = new String[] { "五戒圈", "四肢酥", "三炫环", "绛云朱环",
				"灭渡金环", "白玉金刚镯", "九天离火轮", "白玉环", "金光镯", "九幽玄冥轮", "锁龙环", "元慈光圈",
				"乾坤圈" };
		String[] names = null;
		switch (type) {
		case 武器:
			names = weaponNames;
			break;
		case 衣服:
			names = clothNames;
			break;
		case 头盔:
			names = headNames;
			break;
		case 鞋子:
			names = shoeNames;
			break;
		case 玉佩:
			names = yuNames;
			break;
		case 挂坠:
			names = zhuiNames;
			break;
		case 手镯:
			names = shouNames;
			break;
		default:
			break;
		}
		if (names == null) {
			return "未知";
		}
		int index = level / 10;
		if (index >= names.length) {
			return "未知";
		}
		return names[index];
	}

	// 是否为装备名
	public static boolean isEquipName(String name) {
		String[] weaponNames = new String[] { "阴阳剑", "二龙剑", "青云剑", "飞烟剑",
				"指尘剑", "腾空剑", "血目剑", "巨阙剑", "青萍剑", "逸龙剑", "轩辕剑", "娲皇剑", "诛仙剑",

				"五行盔", "金霞冠", "指天帽", "云烟冠", "太乙木冠", "九天玄盔", "九焰冠", "冲天盔",
				"星耀冠", "蚩尤盔", "轩辕冠", "娲女冠", "乾坤冠",

				"五行法衣", "扫霞衣", "昊天云衣", "七皂罗衫", "净尘衫", "九天玄甲", "南明离火服", "洪荒龟甲",
				"八卦紫绶衣", "蚩尤魔甲", "黄帝袍", "红彤羽衣", "紫绶仙衣",

				"五光鞋", "五色履", "追云靴", "七皂罗靴", "疾风靴", "空明玄足", "风火轮", "逐日靴",
				"紫绶鞋", "冥河支腿", "混元靴", "无影鞋", "云蛟履",

				"五行玉", "紫霞宝玉", "七香坠", "玲珑七窍心", "无垢坠", "和氏璧", "颜如玉", "盘天坠",
				"龙虎如意", "乱心尘", "九州龙鼎玉玺", "彼女坠", "三宝玉如意",

				"戳目珠", "定海珠", "定风珠", "日月珠", "劈地珠", "红珠", "乾天火灵珠", "一元珠",
				"霹雳雷火珠", "凝血神珠", "混元宝珠", "开天珠", "乾坤珠",

				"五戒圈", "四肢酥", "三炫环", "绛云朱环", "灭渡金环", "白玉金刚镯", "九天离火轮", "白玉环",
				"金光镯", "九幽玄冥轮", "锁龙环", "元慈光圈", "乾坤圈" };
		for (String equipName : weaponNames) {
			if (equipName.equals(name)) {
				return true;
			}
		}
		return false;
	}

	public static MmochatEquipQualityType getMaxQuality(
			MmochatEquipQualityType curQuality,
			MmochatEquipQualityType newQuality) {
		if (newQuality.getPrority() > curQuality.getPrority()) {
			return newQuality;
		}
		return curQuality;
	}

	// 获取每类属性的可选属性:基础、附加、粉属性、套装明属性、套装暗属性、改造属性
	public static List<MmochatEquipAttributeType> getEquipAttributeTypes(
			MmochatEquipType equipType,
			MmochatEquipAttributeQualityType attrQuality) {
		List<MmochatEquipAttributeType> attrList = new ArrayList<MmochatEquipAttributeType>();

		MmochatEquipAttributeType[] baseAttrType = null; // 基础属性
		MmochatEquipAttributeType[] randAttrType = null; // 附加属性、粉属性
		MmochatEquipAttributeType[] greenLightAttrType = null; // 套装明属性
		MmochatEquipAttributeType[] greenDarkAttrType = null; // 套装暗属性
		MmochatEquipAttributeType[] modifyAttrType = null; // 改造属性

		switch (equipType) {
		case 武器: {
			baseAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.伤害 };
			modifyAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.伤害 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.伤害,
					MmochatEquipAttributeType.物理暴击,
					MmochatEquipAttributeType.法术暴击,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒,
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.伤害,
					MmochatEquipAttributeType.物理暴击,
					MmochatEquipAttributeType.法术暴击,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒 };
			greenLightAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物伤加成,
					MmochatEquipAttributeType.法伤加成,
					MmochatEquipAttributeType.物理致命一击,
					MmochatEquipAttributeType.法术致命一击,
					MmochatEquipAttributeType.物理破防,
					MmochatEquipAttributeType.法术破防,
					MmochatEquipAttributeType.强化封印,
					MmochatEquipAttributeType.强化冰冻,
					MmochatEquipAttributeType.强化混乱,
					MmochatEquipAttributeType.强化全异常,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒 };
			greenDarkAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物伤, MmochatEquipAttributeType.法伤,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.速度 };
			break;
		}
		case 头盔:
		case 衣服: {
			baseAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血 };
			modifyAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.防御 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒, MmochatEquipAttributeType.力量,
					MmochatEquipAttributeType.灵力, MmochatEquipAttributeType.敏捷,
					MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒, };
			greenLightAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物防加成,
					MmochatEquipAttributeType.法防加成,
					MmochatEquipAttributeType.物理致命抵抗,
					MmochatEquipAttributeType.法术致命抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			greenDarkAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物伤, MmochatEquipAttributeType.法伤,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.速度 };
			break;
		}
		case 鞋子: {
			baseAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.速度 };
			modifyAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.防御 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒, MmochatEquipAttributeType.力量,
					MmochatEquipAttributeType.灵力, MmochatEquipAttributeType.敏捷,
					MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			greenLightAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物理致命抵抗,
					MmochatEquipAttributeType.法术致命抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.物理闪避,
					MmochatEquipAttributeType.法术闪避,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			greenDarkAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.物伤, MmochatEquipAttributeType.法伤,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.速度 };
			break;
		}
		case 玉佩: {
			baseAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.气血 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.气血, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.物防加成,
					MmochatEquipAttributeType.法防加成,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒, MmochatEquipAttributeType.力量,
					MmochatEquipAttributeType.灵力, MmochatEquipAttributeType.敏捷,
					MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.气血, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 挂坠: {
			baseAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.防御 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.物防加成,
					MmochatEquipAttributeType.法防加成,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒, MmochatEquipAttributeType.力量,
					MmochatEquipAttributeType.灵力, MmochatEquipAttributeType.敏捷,
					MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 手镯: {
			baseAttrType = new MmochatEquipAttributeType[] { MmochatEquipAttributeType.伤害 };
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.伤害, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.物伤加成,
					MmochatEquipAttributeType.法伤加成,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒,
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.伤害, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒 };
			break;
		}
		default:
			return null;
		}

		MmochatEquipAttributeType[] attr = null;
		switch (attrQuality) {
		case 基础属性:
			attr = baseAttrType;
			break;
		case 附加属性:
		case 粉属性:
			attr = randAttrType;
			break;
		case 套装明属性:
			attr = greenLightAttrType;
			break;
		case 套装暗属性:
			attr = greenDarkAttrType;
			break;
		case 改造属性:
			attr = modifyAttrType;
			break;
		default:
			break;
		}
		if (attr != null) {
			for (int i = 0; i < attr.length; i++) {
				attrList.add(attr[i]);
			}
		}

		return attrList;
	}

	// 获取装备可附加的随机属性类型，且不重复
	public static List<MmochatEquipAttributeType> getEquipRandAttributeTypesWithoutOverlap(
			MmochatEquipType equipType) {

		List<MmochatEquipAttributeType> attrList = new ArrayList<MmochatEquipAttributeType>();
		MmochatEquipAttributeType[] randAttrType = null; // 附加属性、粉属性

		switch (equipType) {
		case 武器: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.伤害,
					MmochatEquipAttributeType.物理暴击,
					MmochatEquipAttributeType.法术暴击,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒 };
			break;
		}
		case 头盔:
		case 衣服: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.气血,
					MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 鞋子: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.物理暴击抵抗,
					MmochatEquipAttributeType.法术暴击抵抗,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 玉佩: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.气血, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.物防加成,
					MmochatEquipAttributeType.法防加成,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 挂坠: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.防御, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.封印抵抗,
					MmochatEquipAttributeType.冰冻抵抗,
					MmochatEquipAttributeType.混乱抵抗,
					MmochatEquipAttributeType.全异常抵抗,
					MmochatEquipAttributeType.物防加成,
					MmochatEquipAttributeType.法防加成,
					MmochatEquipAttributeType.抗雷, MmochatEquipAttributeType.抗水,
					MmochatEquipAttributeType.抗毒 };
			break;
		}
		case 手镯: {
			randAttrType = new MmochatEquipAttributeType[] {
					MmochatEquipAttributeType.力量, MmochatEquipAttributeType.灵力,
					MmochatEquipAttributeType.敏捷, MmochatEquipAttributeType.体质,
					MmochatEquipAttributeType.全属性,
					MmochatEquipAttributeType.野蛮, MmochatEquipAttributeType.智慧,
					MmochatEquipAttributeType.坚韧, MmochatEquipAttributeType.活力,
					MmochatEquipAttributeType.灵巧,
					MmochatEquipAttributeType.全天赋,
					MmochatEquipAttributeType.伤害, MmochatEquipAttributeType.法力,
					MmochatEquipAttributeType.速度,
					MmochatEquipAttributeType.忽视封印抵抗,
					MmochatEquipAttributeType.忽视冰冻抵抗,
					MmochatEquipAttributeType.忽视混乱抵抗,
					MmochatEquipAttributeType.忽视全异常抵抗,
					MmochatEquipAttributeType.物伤加成,
					MmochatEquipAttributeType.法伤加成,
					MmochatEquipAttributeType.忽视抗雷,
					MmochatEquipAttributeType.忽视抗水,
					MmochatEquipAttributeType.忽视抗毒 };
			break;
		}
		default:
			return null;
		}

		if (randAttrType != null) {
			for (int i = 0; i < randAttrType.length; i++) {
				attrList.add(randAttrType[i]);
			}
		}

		return attrList;

	}

	/*
	 * 随机生成一件装备 equipType: 装备类型; equipLevel:装备等级; maxQuality:品质;
	 * 不生成粉属性、套装属性、改造属性 ；首饰只生成0级无随机属性
	 */
	public static MmochatEquip createRandomEquip(boolean isPlayerEquip,
			MmochatEquipType equipType, int equipLevel1,
			MmochatEquipQualityType quality) {
		boolean isJewelry = false;
		if (equipType == MmochatEquipType.玉佩
				|| equipType == MmochatEquipType.手镯
				|| equipType == MmochatEquipType.挂坠) {
			isJewelry = true;
			equipLevel1 = 0;
			quality = MmochatEquipQualityType.金装;
		}
		int equipLevel = equipLevel1 / 10 * 10;
		if (equipLevel < 0) {
			equipLevel = 0;
		}
		int equipLifeTurn = 0;// 几转
		if (equipLevel > MmochatConstant.equipMaxLevel) {
			equipLifeTurn = (equipLevel - MmochatConstant.equipMaxLevel) / 10;
			equipLevel = MmochatConstant.equipMaxLevel;
		}
		equipLifeTurn = Math.min(equipLifeTurn, MmochatConstant.maxLifeTurn);
		MmochatEquip equip;
		if (isPlayerEquip) {
			equip = new MmochatEquip(true);
		} else {
			equip = new MmochatEquip(false);
		}
		equip.setName(getEquipName(equipType, equipLevel));
		equip.setLevelNeed(equipLevel);
		equip.setLife_turn(equipLifeTurn);
		if (equipLifeTurn > 0) {
			if (MmochatUtil.isInPercent(50)) {
				equip.setSecond_role_type(MmochatSecondRoleType.仙道);
			} else {
				equip.setSecond_role_type(MmochatSecondRoleType.魔道);
			}
		}
		equip.setEquipType(equipType);
		equip.setQuality(quality);

		// 设置基础属性
		List<MmochatEquipAttributeType> baseAttrType = getEquipAttributeTypes(
				equipType, MmochatEquipAttributeQualityType.基础属性);
		for (MmochatEquipAttributeType attrType : baseAttrType) {
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(attrType);
			attr.setValue(getEquipBaseAttrValue(equipType, equip
					.getEquipTrueLevel(), attrType));
			equip.addBaseAttr(attr);
		}
		// 设置随机属性(首饰不生成随机属性)
		if (quality.getPrority() > MmochatEquipQualityType.白装.getPrority()
				&& !isJewelry) {
			List<MmochatEquipAttributeType> randAttrList = getEquipAttributeTypes(
					equipType, MmochatEquipAttributeQualityType.附加属性);

			int maxAttrNum = 0, minAttrNum = 0;
			switch (quality) {
			case 蓝装:
				// 1~3条附加属性
				minAttrNum = 1;
				maxAttrNum = 3;
				break;
			default:
				// 3~5条附加属性
				minAttrNum = 3;
				maxAttrNum = 5;
				break;
			}
			int randAttrNum = MmochatUtil
					.getRandomValue(minAttrNum, maxAttrNum);
			int sumPrority = 0;
			for (MmochatEquipAttributeType type : randAttrList) {
				sumPrority += type.getPrority();
			}
			for (int i = 0; i < randAttrNum; i++) {
				if (sumPrority <= 0) {
					break;
				}
				// 根据属性权值决定属性出现的机率
				int prority = MmochatUtil.getRandomValue(sumPrority);
				int curPrority = 0;
				MmochatEquipAttributeType attrType = null;
				for (MmochatEquipAttributeType type : randAttrList) {
					curPrority += type.getPrority();
					if (curPrority > prority) {
						attrType = type;
						break;
					}
				}
				if (attrType == null) {
					log
							.error("-------------createRandomEquip error:attrType == null");
					continue;
				}
				randAttrList.remove(attrType);
				sumPrority -= attrType.getPrority();
				try {
					Integer[] values = equipRandAttrData.get(equipType).get(
							attrType).get(equip.getEquipTrueLevel());
					int attrValue = MmochatUtil.getRandomValue(values[0],
							values[1]);
					MmochatEquipAttribute attr = new MmochatEquipAttribute();
					attr.setType(attrType);
					attr.setValue(attrValue);
					equip.addRandAttr(attr);
				} catch (Exception e) {
					e.printStackTrace();
					continue;
				}
			}
		}
		return equip;
	}

	// 装备掉落
	// minLevel,maxLevel:装备等级范围
	// whiteEquipPercent,blueEquipPercent,orangeEquipPercent:白装,蓝装,金装机率
	public static MmochatEquip getRandEquip(int minLevel, int maxLevel,
			double whiteEquipPercent, double blueEquipPercent,
			double orangeEquipPercent) {
		MmochatEquipQualityType quality = null;
		double percent = Math.random() * 100;
		if (percent < orangeEquipPercent) {
			quality = MmochatEquipQualityType.金装;
		} else if (percent < orangeEquipPercent + blueEquipPercent) {
			quality = MmochatEquipQualityType.蓝装;
		} else if (percent < orangeEquipPercent + blueEquipPercent
				+ whiteEquipPercent) {
			quality = MmochatEquipQualityType.白装;
		}
		if (quality == null) {
			return null;
		}
		List<MmochatEquipType> equipTypeList = new ArrayList<MmochatEquipType>();
		equipTypeList.add(MmochatEquipType.武器);
		equipTypeList.add(MmochatEquipType.头盔);
		equipTypeList.add(MmochatEquipType.衣服);
		equipTypeList.add(MmochatEquipType.鞋子);
		int index = MmochatUtil.getRandomValue(equipTypeList.size());
		MmochatEquipType equipType = equipTypeList.get(index);
		int level = MmochatUtil.getRandomValue(minLevel, maxLevel);

		MmochatEquip equip = createRandomEquip(true, equipType, level, quality);
		return equip;
	}

	// 根据参数设置怪物数值
	public static MmochatMonster setMonsterBattleParam(
			MmochatMonsterFactory monsterFactory) {
		MmochatMonster monster = monsterFactory.getClone();

		int level = monsterFactory.getLevel();// 等级(0-220)
		int life_turn = (level - 120) / 10;
		int equipLevel = monsterFactory.getEquipLevel();// 装备锻造等级
		double teamNum = monsterFactory.getTeamNum();// 队伍伤害输出人数
		double killRound = monsterFactory.getKillRound();// 消灭回合数
		double physicalParam = monsterFactory.getPhysical();// 物伤系数
		double magicParam = monsterFactory.getMagic();// 法伤系数
		int speedPointAddType = monsterFactory.getSpeedPointAddType();// 速度系数

		List<MmochatEquip> equips = new ArrayList<MmochatEquip>();
		MmochatEquip equip = createRandomEquip(false, MmochatEquipType.头盔,
				level, MmochatEquipQualityType.白装);
		equip.setEquipModifyLevel(equipLevel);
		equips.add(equip);
		equip = createRandomEquip(false, MmochatEquipType.武器, level,
				MmochatEquipQualityType.白装);
		equip.setEquipModifyLevel(equipLevel);
		equips.add(equip);
		equip = createRandomEquip(false, MmochatEquipType.衣服, level,
				MmochatEquipQualityType.白装);
		equip.setEquipModifyLevel(equipLevel);
		equips.add(equip);
		equip = createRandomEquip(false, MmochatEquipType.鞋子, level,
				MmochatEquipQualityType.白装);
		equip.setEquipModifyLevel(equipLevel);
		equips.add(equip);

		// 天赋点分配
		int totalGift = level / 2;// 总天赋点数
		int firstGift = Math.min(MmochatConstant.getMaxNumPerGift(life_turn),
				totalGift);// 主天赋点数(优先加满此天赋)
		int secondGift = Math.max(0, totalGift - firstGift);// 次天赋点数
		secondGift = Math.min(MmochatConstant.getMaxNumPerGift(life_turn),
				secondGift);
		int thirdGift = Math.max(0, totalGift - firstGift - secondGift); // 第三天赋点数
		thirdGift = Math.min(MmochatConstant.getMaxNumPerGift(life_turn),
				thirdGift);
		// 属性点数
		int mainPointNum = level * 5;// 主属性点数(可分配点全加在主属性上)
		int secondPointNum = level;// 次属性点数

		// 全力人天赋:野蛮，活力，坚韧; 全灵人天赋:智慧，活力，坚韧
		// 计算全力人的血、物防、物伤;全灵人的血、法防
		int pBlood;// 全力人的血
		int pPhysicalDefend;// 全力人的物防
		int pPhysicalAttack;// 全力人的物伤
		int mBlood;// 全灵人的血
		int mMagicDefend;// 全灵人的法防
		{
			// 全力人的血
			int bloodPointNum = secondPointNum;
			int bloodGiftPointNum = secondGift;
			int equipBlood = 0;
			for (MmochatEquip equip1 : equips) {
				bloodPointNum += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.体质);
				bloodGiftPointNum += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.活力);
				equipBlood += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.气血);

			}

			pBlood = (int) (100 + 50 * level + 24 * bloodPointNum
					* (1 + bloodGiftPointNum * 0.03) + equipBlood);
			mBlood = pBlood;
		}
		{
			// 全力人的物防
			int bloodPoint = secondPointNum;
			int defendGiftPoint = thirdGift;
			int equipDefend = 0;
			int equipDefendPercent = 0;
			for (MmochatEquip equip1 : equips) {
				defendGiftPoint += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
				equipDefend += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.防御);
				equipDefendPercent += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.物防加成);

			}
			pPhysicalDefend = (int) ((50 + 8 * level + 8 * bloodPoint
					* (1 + defendGiftPoint * 0.03) + equipDefend) * (1 + equipDefendPercent / 100.0));
		}
		{
			// 全力人的物伤
			int attackPoint = mainPointNum;
			int attackGiftPoint = firstGift;
			int equipAttack = 0;
			int equipPhysicalAttack = 0;
			int equipAttackPercent = 0;

			for (MmochatEquip equip1 : equips) {
				attackGiftPoint += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.野蛮);
				equipAttack += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.伤害);
				equipPhysicalAttack += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.物伤);
				equipAttackPercent += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.物伤加成);

			}

			pPhysicalAttack = (int) ((100 + 10 * level + 15 * attackPoint
					* (1 + attackGiftPoint * 0.03) + equipAttack + equipPhysicalAttack) * (1 + equipAttackPercent / 100.0));
		}
		{
			// 全灵人的法防
			int bloodPoint = secondPointNum;
			int defendGiftPoint = thirdGift;
			int equipDefend = 0;
			int equipDefendPercent = 0;
			for (MmochatEquip equip1 : equips) {
				defendGiftPoint += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.坚韧);
				equipDefend += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.防御);
				equipDefendPercent += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.法防加成);

			}
			mMagicDefend = (int) ((50 + 8 * level + 8 * bloodPoint
					* (1 + defendGiftPoint * 0.03) + equipDefend) * (1 + equipDefendPercent / 100.0));
		}
		// 物伤:物伤系数*全力人血+全力人物防
		int pAttack = (int) (physicalParam * pBlood + pPhysicalDefend);

		// 法伤:法伤系数*全灵人血/MmochatConstant.monsterSkillHurtParam+全灵人法防
		int mAttack = (int) (magicParam * mBlood
				/ MmochatConstant.monsterSkillHurtParam + mMagicDefend);

		// 气血:消灭回合数*队伍伤害输出人数*全力人物伤
		int blood = (int) (killRound * teamNum * pPhysicalAttack);

		// 速度:敏捷点=(1+速度系数)*等级，(灵巧)计算出的人的速度
		int speed;
		{
			int speedPoint = level * (1 + speedPointAddType);
			int speedGiftPoint = firstGift;
			int equipSpeed = 0;
			for (MmochatEquip equip1 : equips) {
				speedGiftPoint += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.灵巧);
				equipSpeed += equip1
						.getEquipAttrValue(MmochatEquipAttributeType.速度);

			}
			speed = (int) (100 + 5 * level + 5 * speedPoint
					* (1 + speedGiftPoint * 0.03) + equipSpeed);
		}
		monster.setPhysicalAttack(pAttack);
		monster.setSpritAttack(mAttack);
		monster.setTotalBlood(blood);
		monster.setSpeed(speed);
		return monster;
	}

	// 14.12 制作装备
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_14_12(SkymobiHandler handler,
			Mmochat_14_12C req) {
		try {
			MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
					.getRoleId());
			if (me == null) {
				return new Mmochat_14_12S(req.getHallState(), "服务器忙,请稍候再试!");
			}

			if (!me.lockState(MmochatRoleStateType.改造装备时)) {
				return null;
			}

			List<Integer> gridIds = req.getGridIds();
			List<MmochatPackageGrid> objs = new ArrayList<MmochatPackageGrid>();
			for (Integer gridId : gridIds) {
				MmochatPackageGrid grid = me.getMyPackage().get(gridId);
				if (grid == null || !grid.hasObj()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不存在!");
				}
				objs.add(grid);
			}

			// 检查是否有借来的东西
			for (MmochatPackageGrid grid : objs) {
				MmochatCommonObject obj = grid.getObject();
				if (obj == null) {
					continue;
				}
				if (obj.getBorrowFromRoleId() != null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"提交的物品有向他人借来的物品，无法进行本次操作!");
				}
			}

			MmochatNpcItemType type = MmochatNpcItemType.get(req
					.getMakeTypeId());
			switch (type) {
			case 装备改造: {
				// 装备+2块改造石+混沌石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "改造需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_superModify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_superModifyBall = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_noDestroy = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.改造石) {
							prop_modify.add(grid);
						} else if (obj.getPropType() == MmochatPropType.超级改造石) {
							prop_superModify.add(grid);
						} else if (obj.getPropType() == MmochatPropType.改造灵珠) {
							prop_superModifyBall.add(grid);
						} else if (obj.getPropType() == MmochatPropType.混沌石) {
							prop_noDestroy.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交一件要改造的装备!");
				}
				if ((prop_modify.size() > 0 && prop_superModify.size() > 0)
						|| (prop_superModifyBall.size() > 0 && prop_modify
								.size() > 0)
						|| (prop_superModifyBall.size() > 0 && prop_superModify
								.size() > 0)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"改造石、超级改造石、改造灵珠三类改造道具只能提交其中一种!不能混合提交。");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "此物品无法改造!");
				}
				// 检查改造石:数量
				if (equip.getEquipQuality() == MmochatEquipQualityType.白装) {
					if (prop_modify.size() > 0) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"白装备改造不需要改造石!");
					}
				} else {
					int num = 0, num1 = 0, num2 = 0;
					for (MmochatPackageGrid grid : prop_modify) {
						if (grid.getObject() != null) {
							num += grid.getObject().getOverlapNum();
						}
					}
					for (MmochatPackageGrid grid : prop_superModify) {
						if (grid.getObject() != null) {
							num1 += grid.getObject().getOverlapNum();
						}
					}
					for (MmochatPackageGrid grid : prop_superModifyBall) {
						if (grid.getObject() != null) {
							num2 += grid.getObject().getOverlapNum();
						}
					}
					if (num < 2 && num1 < 2 && num2 < 2) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请提交2块改造石，或2块超级改造石，或2块改造灵珠!");
					}
				}

				// 改造上限
				int equipModifyLevel = equip.getEquipModifyLevel();
				if (equipModifyLevel >= MmochatConstant.maxEquipModifyLevel) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备已达改造上限,无法改造!");
				}

				// 6改7以上时，混沌石判断
				boolean destroy = true;
				if (equipModifyLevel >= 6) {
					if (prop_noDestroy.size() > 0) {
						MmochatPackageGrid grid = prop_noDestroy.get(0);
						if (grid != null) {
							MmochatCommonObject obj = grid.getObject();
							if (obj != null) {
								if (obj.getOverlapNum() > 0) {
									destroy = false;
								}
							}
						}
					}
					if (destroy) {
						// 如果6改7以上时，没放混沌，下发提醒
						String msg = "本次改造"
								+ MmochatUtil.wrapColor("失败时装备会消失", Color.red)
								+ ",提交"
								+ MmochatUtil.wrapColor("混沌石", Color.green)
								+ "可防止装备消失。您确定要继续改造么?";
						CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
						msgbox.setContent(new Text(msg));
						msgbox.setLeftName("改造");
						msgbox.setRightName("取消");
						msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
						msgbox.addLeftTLV(new AddDataTLV((int) req
								.getMakeTypeId()));
						msgbox.addLeftTLV(new AddDataTLV((int) gridIds.size()));
						for (Integer gridId : gridIds) {
							msgbox.addLeftTLV(new AddDataTLV((int) gridId));
						}
						msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
								.getClientModuleId(), MmochatMain
								.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_14_13, null));

						ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
						wait.setShowCancel(false);
						msgbox.addLeftTLV(wait);

						me.unLockState();
						return MmochatUtil.tlvResponse(req.getHallState(),
								msgbox);
					}
				}

				// 开始改造
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除道具
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				int needNum = 2;
				boolean useSuperModify = false; // 使用超级改造石增加成功机率
				boolean useModifyBall = false;// 使用改造灵珠

				// 改造石
				if (prop_modify.size() > 0) {
					for (MmochatPackageGrid grid : prop_modify) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null) {
							if (obj.getOverlapNum() > needNum) {
								obj.delOverlapNum(needNum);
								needNum = 0;
							} else {
								grid.setObject(null);
								needNum -= obj.getOverlapNum();
								obj.setOverlapNum(0);
							}
							gridNeedUpdate.add(grid);
							if (needNum <= 0) {
								break;
							}
						}
					}
					MmochatStatisticsService.addPropCost(MmochatPropType.改造石,
							Math.min(prop_modify.size(), 2));
				} else if (prop_superModify.size() > 0) {
					useSuperModify = true;
					for (MmochatPackageGrid grid : prop_superModify) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null) {
							if (obj.getOverlapNum() > needNum) {
								obj.delOverlapNum(needNum);
								needNum = 0;
							} else {
								grid.setObject(null);
								needNum -= obj.getOverlapNum();
								obj.setOverlapNum(0);
							}
							gridNeedUpdate.add(grid);
							if (needNum <= 0) {
								break;
							}
						}
					}
					MmochatStatisticsService.addPropCost(MmochatPropType.超级改造石,
							Math.min(prop_superModify.size(), 2));
				} else if (prop_superModifyBall.size() > 0) {
					useModifyBall = true;
					for (MmochatPackageGrid grid : prop_superModifyBall) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null) {
							if (obj.getOverlapNum() > needNum) {
								obj.delOverlapNum(needNum);
								needNum = 0;
							} else {
								grid.setObject(null);
								needNum -= obj.getOverlapNum();
								obj.setOverlapNum(0);
							}
							gridNeedUpdate.add(grid);
							if (needNum <= 0) {
								break;
							}
						}
					}
					MmochatStatisticsService.addPropCost(MmochatPropType.改造灵珠,
							Math.min(prop_superModifyBall.size(), 2));
				}

				// 混沌石，6改7以前，不消耗混沌
				if (equipModifyLevel >= 6) {
					if (prop_noDestroy.size() > 0) {
						MmochatPackageGrid grid = prop_noDestroy.get(0);
						if (grid != null) {
							MmochatCommonObject obj = grid.getObject();
							if (obj != null) {
								if (obj.getOverlapNum() > 1) {
									obj.delOverlapNum(1);
									gridNeedUpdate.add(grid);
								} else if (obj.getOverlapNum() == 1) {
									grid.setObject(null);
									gridNeedUpdate.add(grid);
								}
							}
						}
						MmochatStatisticsService.addPropCost(
								MmochatPropType.混沌石, 1);
					}
				}

				// 成功率
				double rate = modifyRate[equipModifyLevel];
				if (useSuperModify) {
					rate = rate + 50;
				} else if (useModifyBall) {
					rate = 50;
				}

				String userMsg;
				String systemMsg = null;
				if (equipModifyLevel <= 5) {
					// 改6前都不爆
					log.debug("改造成功率:" + rate + "%");
					if (MmochatUtil.isInPercent(rate)) {
						// 改造成功
						equipModifyLevel = Math.min(
								MmochatConstant.maxEquipModifyLevel,
								equipModifyLevel + 1);
						equip.setEquipModifyLevel(equipModifyLevel);
						userMsg = MmochatUtil.wrapColor("恭喜您，改造成功了！装备的改造等级提升到"
								+ equip.getEquipModifyLevel() + "级。",
								Color.green);
					} else {
						// 改造失败
						if (!useModifyBall) {
							equipModifyLevel = Math
									.max(0, equipModifyLevel - 1);
						}
						equip.setEquipModifyLevel(equipModifyLevel);
						userMsg = MmochatUtil
								.wrapColor("真遗憾，改造失败了！当前改造等级为"
										+ equip.getEquipModifyLevel() + "级。",
										Color.red);
					}
				} else {
					// 改7及以上
					log.debug("改造成功率:" + rate + "%");
					if (MmochatUtil.isInPercent(rate)) {
						// 改造成功
						equipModifyLevel = Math.min(
								MmochatConstant.maxEquipModifyLevel,
								equipModifyLevel + 1);
						equip.setEquipModifyLevel(equipModifyLevel);
						userMsg = MmochatUtil.wrapColor("恭喜您，改造成功了！装备的改造等级提升到"
								+ equip.getEquipModifyLevel() + "级。",
								Color.green);
						if (equip.getEquipModifyLevel() >= 15) {
							systemMsg = MmochatUtil.wrapColor(me.getName(),
									Color.green)
									+ MmochatUtil.wrapColor("将"
											+ MmochatUtil.wrapColor(equip
													.getName(), equip
													.getEquipQuality()
													.getColor()) + "改"
											+ equip.getEquipModifyLevel()
											+ "了,难道这就是传说中的狗屎运?", Color.yellow);
						}
					} else {
						// 改造失败
						if (!destroy) {
							if (!useModifyBall) {
								equipModifyLevel = Math.max(0,
										equipModifyLevel - 1);
							}
							equip.setEquipModifyLevel(equipModifyLevel);
							userMsg = MmochatUtil.wrapColor("真遗憾，改造失败了！当前改造等级为"
									+ equip.getEquipModifyLevel() + "级。",
									Color.red);
						} else {
							// 装备消失
							equipGrid.setObject(null);
							userMsg = MmochatUtil.wrapColor(
									"真遗憾，改造失败了!当前装备消失。(改7以上，未使用混沌石，失败时装备消失)",
									Color.red);
						}
					}
				}
				gridNeedUpdate.add(equipGrid);

				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备改造, -1 * modifyPrice);
				if (systemMsg != null) {
					MmochatChatService.sendSystemMsg(systemMsg);
				}

				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 属性抽取: {
				// 装备+白水晶/超级白水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "属性抽取需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_superModify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.白水晶) {
							prop_modify.add(grid);
						} else if (obj.getPropType() == MmochatPropType.超级白水晶) {
							prop_superModify.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交要抽取属性的装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交一件要抽取属性的装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交要抽取属性的装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交要抽取属性的装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "此物品无法抽取属性!");
				}
				if (equip.getEquipRandAttr().size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交具有附加属性的装备!");
				}
				if (equip.getLife_turn() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交未转生的装备!");
				}
				if (!me.hasEnoughPackageSpace(1)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请保留至少一个包裹空位!");
				}
				// 检查白水晶
				MmochatPackageGrid propGrid = null;
				MmochatCommonObject modifyProp = null;
				if (prop_modify.size() > 0) {
					MmochatPackageGrid grid = prop_modify.get(0);
					if (grid != null) {
						propGrid = grid;
						modifyProp = grid.getObject();
					}
				} else if (prop_superModify.size() > 0) {
					MmochatPackageGrid grid = prop_superModify.get(0);
					if (grid != null) {
						propGrid = grid;
						modifyProp = grid.getObject();
					}
				}
				if (modifyProp == null || propGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一块白水晶或超级白水晶!");
				}
				if (modifyProp.getEquipAttrInProp() != null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "此"
							+ modifyProp.getPropType().toString()
							+ "已经吸附了一条装备属性，无法再吸附。");
				}

				// 开始抽取属性
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				boolean success = false;
				if (modifyProp.getPropType() == MmochatPropType.超级白水晶) {
					success = true;
					MmochatStatisticsService.addPropCost(MmochatPropType.超级白水晶,
							1);
				} else if (MmochatUtil.isInPercent(separateEquipAttrRate)) {
					success = true;
					MmochatStatisticsService
							.addPropCost(MmochatPropType.白水晶, 1);
				} else {
					MmochatStatisticsService
							.addPropCost(MmochatPropType.白水晶, 1);
				}
				String userMsg = "很遗憾!抽取失败，"
						+ modifyProp.getPropType().toString() + "消失。";
				// 扣除一个道具
				if (modifyProp.getOverlapNum() > 1) {
					modifyProp.delOverlapNum(1);
				} else {
					propGrid.setObject(null);
				}
				gridNeedUpdate.add(propGrid);

				if (success) {
					// 抽取成功，生成黑水晶，装备中随机一条属性转移到黑水晶上
					int attrNum = equip.getEquipRandAttr().size();
					if (attrNum > 0) {
						int index = MmochatUtil.getRandomValue(attrNum);
						MmochatEquipAttribute attr = equip.getEquipRandAttr()
								.remove(index);
						if (attr != null) {
							MmochatProp newProp = new MmochatProp(
									MmochatPropType.黑水晶);
							newProp.setEquipAttrInProp(attr);
							newProp.setLevelOfEquipAttrInProp(equip
									.getEquipLevelNeed());
							newProp.setEquipTypeOfEquipAttrInProp(equip
									.getEquipType());
							gridNeedUpdate.addAll(me.addObjectToPackage(
									newProp, false));
							gridNeedUpdate.add(equipGrid);
							userMsg = "恭喜!抽取属性成功!";
						}
					}
				}
				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.属性抽取, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 装备合成: {
				// 装备+3黑水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备合成需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.黑水晶) {
							prop_modify.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件白装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件白装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件白装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件白装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.白装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交白装，白装可到武器店或防具店里购买!");
				}
				if (equip.getEquipModifyLevel() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交未改造的白装，白装可到武器店或防具店里购买!");
				}
				if (equip.getLife_turn() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交未转生的白装!");
				}

				// 检查黑水晶:是否3块；是否附带属性；属性类型、等级是否与装备相符；是否有相同类型黑水晶
				if (prop_modify.size() != 3) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请放入三块黑水晶(白水晶或超级白水晶吸附属性后会变成黑水晶)!");
				}
				Map<MmochatEquipAttributeType, MmochatEquipAttribute> attrMap = new HashMap<MmochatEquipAttributeType, MmochatEquipAttribute>();
				for (MmochatPackageGrid grid : prop_modify) {
					if (grid == null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请放入三块黑水晶(白水晶或超级白水晶吸附属性后会变成黑水晶)!");
					}
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请放入三块黑水晶(白水晶或超级白水晶吸附属性后会变成黑水晶)!");
					}
					if (obj.getEquipAttrInProp() == null
							|| obj.getEquipTypeOfEquipAttrInProp() == null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请放入三块黑水晶(白水晶或超级白水晶吸附属性后会变成黑水晶)!");
					}
					if (equip.getEquipLevelNeed() != obj
							.getLevelOfEquipAttrInProp()) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"黑水晶附带的属性等级需要与装备等级一致!");
					}
					if (equip.getEquipType() != obj
							.getEquipTypeOfEquipAttrInProp()) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"黑水晶附带属性的装备类型必须与提交的装备相同!");
					}
					if (attrMap.get(obj.getEquipAttrInProp().getType()) != null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"不能放入两块属性种类相同的黑水晶!您提交了两块"
										+ obj.getEquipAttrInProp().getType()
												.toString() + "属性的黑水晶。");
					} else {
						attrMap.put(obj.getEquipAttrInProp().getType(), obj
								.getEquipAttrInProp());
					}
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除黑水晶
				for (MmochatPackageGrid grid : prop_modify) {
					grid.setObject(null);
					gridNeedUpdate.add(grid);
				}

				// 黑水晶中的属性加到白装备中
				for (MmochatEquipAttribute attr : attrMap.values()) {
					equip.addRandAttr(attr);
					gridNeedUpdate.add(equipGrid);
				}

				// 品质变成蓝装备
				equip.setEquipQuality(MmochatEquipQualityType.蓝装);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "装备合成成功!");
			}
			case 装备粉化: {
				// 蓝装备(粉装备)+粉水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备粉化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.粉水晶) {
							prop_modify.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件蓝装备或粉装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交一件要粉化的装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件蓝装备或粉装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件蓝装备或粉装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.蓝装
						&& equip.getEquipQuality() != MmochatEquipQualityType.粉装
						&& equip.getEquipPinkAttr() == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交蓝装备、粉装备，或有粉属性的绿装备!");
				}

				// 检查粉水晶:数量
				if (prop_modify.size() < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一块粉水晶!");
				}

				// 开始粉化
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除粉水晶
				MmochatPackageGrid grid = prop_modify.get(0);
				if (grid != null) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > 1) {
							obj.delOverlapNum(1);
							gridNeedUpdate.add(grid);
						} else if (obj.getOverlapNum() == 1) {
							grid.setObject(null);
							gridNeedUpdate.add(grid);
						}
					} else {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请提交一块粉水晶!");
					}
				} else {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一块粉水晶!");
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.粉水晶, 1);

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				boolean success = false;
				if (!MmochatUtil.isInPercent(pinkEquipAttrRate)) {
					// 粉化失败
					success = false;
				} else {
					// 生成粉属性:粉属性与随机属性种类最多出现一次重复
					List<MmochatEquipAttributeType> randAttrList = getEquipAttributeTypes(
							equip.getEquipType(),
							MmochatEquipAttributeQualityType.粉属性);
					for (MmochatEquipAttribute attr : equip.getEquipRandAttr()) {
						randAttrList.remove(attr.getType());
					}
					int sumPrority = 0;
					for (MmochatEquipAttributeType type1 : randAttrList) {
						sumPrority += type1.getPrority();
					}
					if (sumPrority > 0) {
						// 根据属性权值决定属性出现的机率
						int prority = MmochatUtil.getRandomValue(sumPrority);
						int curPrority = 0;
						MmochatEquipAttributeType attrType = null;
						for (MmochatEquipAttributeType type1 : randAttrList) {
							curPrority += type1.getPrority();
							if (curPrority > prority) {
								attrType = type1;
								break;
							}
						}
						if (attrType != null) {
							try {
								Integer[] values = equipRandAttrData.get(
										equip.getEquipType()).get(attrType)
										.get(equip.getEquipTrueLevel());
								int attrValue = MmochatUtil.getRandomValue(
										values[0], values[1]);
								MmochatEquipAttribute attr = new MmochatEquipAttribute();
								attr.setType(attrType);
								attr.setValue(attrValue);
								equip.setEquipPinkAttr(attr);
								// 品质变成粉装备
								if (equip.getEquipQuality() == MmochatEquipQualityType.蓝装) {
									equip
											.setEquipQuality(MmochatEquipQualityType.粉装);
								}

								gridNeedUpdate.add(equipGrid);
								// 更新装备制作人
								equip.setEquipMaker(me.getName());
								success = true;
							} catch (Exception e) {
								e.printStackTrace();
							}

						}
					}
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备粉化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				String userMsg;
				if (success) {
					userMsg = "恭喜!装备粉化成功!";
				} else {
					userMsg = "真遗憾!装备粉化失败!";
				}
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 装备金化: {
				// 粉装备+2块金水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备金化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.金水晶) {
							prop_modify.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件粉装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件粉装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件粉装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件粉装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.粉装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交粉装备!");
				}
				// 检查金水晶:数量
				int totalNum = 0;
				for (MmochatPackageGrid grid : prop_modify) {
					MmochatCommonObject prop = grid.getObject();
					if (prop != null) {
						totalNum += prop.getOverlapNum();
					}
				}
				if (totalNum < 2) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交两块金水晶!");
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.金水晶, 2);
				// 开始金化
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除金水晶
				int needNum = 2;
				for (MmochatPackageGrid grid : prop_modify) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 变更品质
				equip.setEquipQuality(MmochatEquipQualityType.金装);
				gridNeedUpdate.add(equipGrid);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备金化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "装备品质提升为金装备!");
			}
			case 制作套装: {
				// 金装备(绿装备)+绿水晶+60个结晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "制作套装需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> materialList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				MmochatMaterialType materialType = null;
				boolean materialIsSame = true; // 材料是否都是同一种
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.绿水晶) {
							prop_modify.add(grid);
						} else {
							other.add(grid);
						}
					} else if (obj.getObjectType() == MmochatObjectType.材料) {
						materialList.add(grid);
						if (materialType == null) {
							materialType = obj.getMaterialType();
						} else {
							if (materialType != obj.getMaterialType()) {
								materialIsSame = false;
							}
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件金装备或绿装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件金装备或绿装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件金装备或绿装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.金装
						&& equip.getEquipQuality() != MmochatEquipQualityType.绿装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交金装备或绿装备!");
				}
				// 检查绿水晶:数量
				if (prop_modify.size() < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一块绿水晶!");
				}
				// 检查材料:数量>=60，种类单一，只能为同等级的结晶
				if (materialType == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一种结晶材料!");
				}
				// 种类单一
				if (!materialIsSame) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一种结晶材料!");
				}
				// 数量>=60
				int totalNum = 0;
				for (MmochatPackageGrid grid : materialList) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						totalNum += obj.getOverlapNum();
					}
				}
				if (totalNum < 60) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"结晶数量不足,请提交60个结晶!");
				}
				// 只能为同等级的结晶
				MmochatMaterialType[] pAttackMaterialList = new MmochatMaterialType[] {
						MmochatMaterialType.三级野蛮结晶, MmochatMaterialType.四级野蛮结晶,
						MmochatMaterialType.五级野蛮结晶, MmochatMaterialType.六级野蛮结晶,
						MmochatMaterialType.七级野蛮结晶, MmochatMaterialType.八级野蛮结晶,
						MmochatMaterialType.九级野蛮结晶, MmochatMaterialType.十级野蛮结晶,
						MmochatMaterialType.十一级野蛮结晶,
						MmochatMaterialType.十二级野蛮结晶 };
				MmochatMaterialType[] mAttackMaterialList = new MmochatMaterialType[] {
						MmochatMaterialType.三级智慧结晶, MmochatMaterialType.四级智慧结晶,
						MmochatMaterialType.五级智慧结晶, MmochatMaterialType.六级智慧结晶,
						MmochatMaterialType.七级智慧结晶, MmochatMaterialType.八级智慧结晶,
						MmochatMaterialType.九级智慧结晶, MmochatMaterialType.十级智慧结晶,
						MmochatMaterialType.十一级智慧结晶,
						MmochatMaterialType.十二级智慧结晶 };
				MmochatMaterialType[] bloodMaterialList = new MmochatMaterialType[] {
						MmochatMaterialType.三级活力结晶, MmochatMaterialType.四级活力结晶,
						MmochatMaterialType.五级活力结晶, MmochatMaterialType.六级活力结晶,
						MmochatMaterialType.七级活力结晶, MmochatMaterialType.八级活力结晶,
						MmochatMaterialType.九级活力结晶, MmochatMaterialType.十级活力结晶,
						MmochatMaterialType.十一级活力结晶,
						MmochatMaterialType.十二级活力结晶 };
				MmochatMaterialType[] defendMaterialList = new MmochatMaterialType[] {
						MmochatMaterialType.三级坚韧结晶, MmochatMaterialType.四级坚韧结晶,
						MmochatMaterialType.五级坚韧结晶, MmochatMaterialType.六级坚韧结晶,
						MmochatMaterialType.七级坚韧结晶, MmochatMaterialType.八级坚韧结晶,
						MmochatMaterialType.九级坚韧结晶, MmochatMaterialType.十级坚韧结晶,
						MmochatMaterialType.十一级坚韧结晶,
						MmochatMaterialType.十二级坚韧结晶 };
				MmochatMaterialType[] speedMaterialList = new MmochatMaterialType[] {
						MmochatMaterialType.三级灵巧结晶, MmochatMaterialType.四级灵巧结晶,
						MmochatMaterialType.五级灵巧结晶, MmochatMaterialType.六级灵巧结晶,
						MmochatMaterialType.七级灵巧结晶, MmochatMaterialType.八级灵巧结晶,
						MmochatMaterialType.九级灵巧结晶, MmochatMaterialType.十级灵巧结晶,
						MmochatMaterialType.十一级灵巧结晶,
						MmochatMaterialType.十二级灵巧结晶 };
				int index = equip.getEquipLevelNeed() / 10 - 3;
				if (index < 0 || index >= pAttackMaterialList.length) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交与装备等级相符的结晶材料!");
				}
				MmochatEquipGiftType equipGiftType = null; // 套装类型
				if (materialType == pAttackMaterialList[index]) {
					equipGiftType = MmochatEquipGiftType.野蛮;
				} else if (materialType == mAttackMaterialList[index]) {
					equipGiftType = MmochatEquipGiftType.智慧;
				} else if (materialType == bloodMaterialList[index]) {
					equipGiftType = MmochatEquipGiftType.活力;
				} else if (materialType == defendMaterialList[index]) {
					equipGiftType = MmochatEquipGiftType.坚韧;
				} else if (materialType == speedMaterialList[index]) {
					equipGiftType = MmochatEquipGiftType.灵巧;
				}
				if (equipGiftType == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交与装备等级相符的结晶材料!");
				}

				// 开始绿化
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除绿水晶
				int needNum = 1;
				for (MmochatPackageGrid grid : prop_modify) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 扣除结晶材料
				needNum = 60;
				for (MmochatPackageGrid grid : materialList) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.绿水晶, 1);
				boolean success = false;
				String info = "";
				if (MmochatUtil.isInPercent(greenEquipAttrRate)) {
					// 制作成功
					// 套装类型
					equip.setEquipGiftType(equipGiftType);
					// 套装明属性
					{
						List<MmochatEquipAttributeType> randAttrList = getEquipAttributeTypes(
								equip.getEquipType(),
								MmochatEquipAttributeQualityType.套装明属性);
						int sumPrority = 0;
						for (MmochatEquipAttributeType type1 : randAttrList) {
							sumPrority += type1.getPrority();
						}
						if (sumPrority > 0) {
							// 根据属性权值决定属性出现的机率
							int prority = MmochatUtil
									.getRandomValue(sumPrority);
							int curPrority = 0;
							MmochatEquipAttributeType attrType = null;
							for (MmochatEquipAttributeType type1 : randAttrList) {
								curPrority += type1.getPrority();
								if (curPrority > prority) {
									attrType = type1;
									break;
								}
							}
							if (attrType != null) {
								try {
									Integer[] values = greenEquipLightAttrData
											.get(equip.getEquipType()).get(
													attrType).get(
													equip.getEquipTrueLevel());
									int attrValue = MmochatUtil.getRandomValue(
											values[0], values[1]);
									MmochatEquipAttribute attr = new MmochatEquipAttribute();
									attr.setType(attrType);
									attr.setValue(attrValue);
									equip.setEquipGreenLightAttr(attr);
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
						}
					}
					// 套装暗属性
					{
						MmochatEquipAttributeType attrType = null;
						switch (equipGiftType) {
						case 野蛮:
							attrType = MmochatEquipAttributeType.物伤;
							break;
						case 智慧:
							attrType = MmochatEquipAttributeType.法伤;
							break;
						case 活力:
							attrType = MmochatEquipAttributeType.气血;
							break;
						case 坚韧:
							attrType = MmochatEquipAttributeType.防御;
							break;
						case 灵巧:
							attrType = MmochatEquipAttributeType.速度;
							break;
						default:
							break;
						}
						if (attrType != null) {
							try {
								Integer[] values = greenEquipDarkAttrData.get(
										equip.getEquipType()).get(attrType)
										.get(equip.getEquipTrueLevel());
								int attrValue = MmochatUtil.getRandomValue(
										values[0], values[1]);
								MmochatEquipAttribute attr = new MmochatEquipAttribute();
								attr.setType(attrType);
								attr.setValue(attrValue);
								equip.setEquipGreenDarkAttr(attr);
								info = "套装暗属性为:" + attrType.toString() + "+"
										+ attrValue + "(最小值:" + values[0]
										+ ",最大值:" + values[1] + ")";
							} catch (Exception e) {
								e.printStackTrace();
							}
						}
					}

					gridNeedUpdate.add(equipGrid);

					// 更新装备制作人
					equip.setEquipMaker(me.getName());

					// 变更品质
					equip.setEquipQuality(MmochatEquipQualityType.绿装);

					success = true;
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.制作套装, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				String userMsg;
				if (success) {
					userMsg = "恭喜!套装制作成功!" + info;
				} else {
					userMsg = "真遗憾!套装制作失败!";
				}
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 套装暗属性强化: {

				// 一件绿装备、一块套装暗属性强化水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备强化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_strenthen = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.套装暗属性强化水晶) {
							prop_strenthen.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.绿装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交绿装备!");
				}
				if (equip.getEquipGreenDarkAttr() == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备中没有套装暗属性，不能强化!");
				}

				// 检查强化水晶:数量
				int prop_strenthenCount = 0;
				for (MmochatPackageGrid grid : prop_strenthen) {
					if (grid.getObject() != null) {
						prop_strenthenCount += grid.getObject().getOverlapNum();
					}
				}
				if (prop_strenthenCount < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一块套装暗属性强化水晶!");
				}

				// 当前明属性
				MmochatEquipAttribute drakAttr = equip.getEquipGreenDarkAttr();

				// 开始强化
				Integer[] values = greenEquipDarkAttrData.get(
						equip.getEquipType()).get(drakAttr.getType()).get(
						equip.getEquipTrueLevel());
				int maxValue = Math.max(values[0], values[1]);
				if (maxValue == drakAttr.getValue()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"装备中套装暗属性数值已达最大值，无法再强化!");
				}

				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除强化水晶
				int needNum = 1;
				for (MmochatPackageGrid grid : prop_strenthen) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.套装暗属性强化水晶,
						1);
				// 属性数值重新生成
				int attrValue = 0;
				int extraAdd = 0;
				boolean success = false;
				int oldAttrValue = drakAttr.getValue();
				try {
					attrValue = MmochatUtil
							.getRandomValue(values[0], values[1]);
					if (attrValue > oldAttrValue) {
						success = true;
						drakAttr.setValue(attrValue);
						gridNeedUpdate.add(equipGrid);
					} else {
						success = false;
						extraAdd = MmochatUtil.getRandomValue(1, 5);
						int newValue = Math.min(values[1], oldAttrValue
								+ extraAdd);
						extraAdd = newValue - oldAttrValue;
						drakAttr.setValue(newValue);
						gridNeedUpdate.add(equipGrid);
					}
				} catch (Exception e) {
					e.printStackTrace();
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备强化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				String userMsg;
				if (success) {
					userMsg = MmochatUtil.wrapColor("恭喜!属性数值强化成功!"
							+ equip.getEquipLevelNeed() + "级套装暗属性<"
							+ drakAttr.getType().toString() + ">最大值为"
							+ maxValue + "，当前值为" + drakAttr.getValue() + "!",
							Color.green);
				} else {
					userMsg = MmochatUtil.wrapColor("强化失败!", Color.red)
							+ "新生成的属性数值为" + attrValue + "，不大于原数值，装备属性数值强制提升"
							+ extraAdd + "点。";
					if (equip.getLife_turn() > 0) {
						userMsg += equip.getLife_turn() + "转";
					}
					userMsg += equip.getEquipLevelNeed() + "级套装暗属性<"
							+ drakAttr.getType().toString() + ">最大值为"
							+ maxValue + "，当前数值为" + drakAttr.getValue() + "。";
					userMsg = MmochatUtil.wrapColor(userMsg, Color.green);
				}
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 套装明属性强化: {
				// 一件绿装备、两块套装明属性强化水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备强化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_strenthen = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.套装明属性强化水晶) {
							prop_strenthen.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.绿装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交绿装备!");
				}
				if (equip.getEquipGreenLightAttr() == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备中没有套装明属性，不能强化!");
				}

				// 检查强化水晶:数量
				int prop_strenthenCount = 0;
				for (MmochatPackageGrid grid : prop_strenthen) {
					if (grid.getObject() != null) {
						prop_strenthenCount += grid.getObject().getOverlapNum();
					}
				}
				if (prop_strenthenCount < 2) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交两块套装明属性强化水晶!");
				}

				// 当前明属性
				MmochatEquipAttribute lightAttr = equip
						.getEquipGreenLightAttr();

				// 开始强化
				Integer[] values = greenEquipLightAttrData.get(
						equip.getEquipType()).get(lightAttr.getType()).get(
						equip.getEquipTrueLevel());
				int maxValue = Math.max(values[0], values[1]);
				if (maxValue == lightAttr.getValue()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"装备中套装明属性数值已达最大值，无法再强化!");
				}

				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除强化水晶
				int needNum = 2;
				for (MmochatPackageGrid grid : prop_strenthen) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.套装明属性强化水晶,
						2);
				// 属性数值重新生成
				int attrValue = 0;
				boolean success = false;
				int oldAttrValue = lightAttr.getValue();
				try {
					attrValue = MmochatUtil
							.getRandomValue(values[0], values[1]);
					if (attrValue > oldAttrValue) {
						success = true;
						lightAttr.setValue(attrValue);
						gridNeedUpdate.add(equipGrid);
					} else {
						success = false;
					}
				} catch (Exception e) {
					e.printStackTrace();
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备强化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				String userMsg;
				if (success) {
					userMsg = MmochatUtil.wrapColor("恭喜!属性数值强化成功!"
							+ equip.getEquipLevelNeed() + "级套装明属性<"
							+ lightAttr.getType().toString() + ">最大值为"
							+ maxValue + "，当前值为" + lightAttr.getValue() + "!",
							Color.green);
				} else {
					userMsg = "强化失败!新生成的属性数值为" + attrValue
							+ "，不大于原数值，装备属性数值保持不变。";
					if (equip.getLife_turn() > 0) {
						userMsg += equip.getLife_turn() + "转";
					}
					userMsg += equip.getEquipLevelNeed() + "级套装明属性<"
							+ lightAttr.getType().toString() + ">最大值为"
							+ maxValue + "!";
					userMsg = MmochatUtil.wrapColor(userMsg, Color.red);
				}
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 装备强化: {
				// 装备+强化水晶+黑水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备强化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_strenthen = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_attr = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.强化水晶) {
							prop_strenthen.add(grid);
						} else if (obj.getPropType() == MmochatPropType.黑水晶) {
							prop_attr.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交武器或者防具!");
				}
				if (equip.getEquipQuality() == MmochatEquipQualityType.白装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "白装无法强化!");
				}
				// 检查强化水晶:数量
				if (prop_strenthen.size() < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一块强化水晶!");
				}
				// 检查(超级)白水晶
				MmochatPackageGrid prop_attr_grid = null;
				if (prop_attr.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一块黑水晶!");
				}
				if (prop_attr.size() > 0) {
					prop_attr_grid = prop_attr.get(0);
				}
				if (prop_attr_grid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一块黑水晶(白水晶或超级白水晶吸附属性后变成黑水晶)!"
									+ "进行强化的属性种类与黑水晶中的属性种类相同。");
				}
				MmochatCommonObject obj = prop_attr_grid.getObject();
				if (obj == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一块黑水晶(白水晶或超级白水晶吸附属性后变成黑水晶)!"
									+ "进行强化的属性种类与黑水晶中的属性种类相同。");
				}
				if (obj.getEquipAttrInProp() == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一块黑水晶(白水晶或超级白水晶吸附属性后变成黑水晶)!"
									+ "进行强化的属性种类与黑水晶中的属性种类相同。");
				}
				if (obj.getLevelOfEquipAttrInProp() != equip
						.getEquipLevelNeed()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"黑水晶吸附的属性的等级必须与装备等级相同。");
				}
				MmochatEquipAttributeType attrTypeToStrenthen = obj
						.getEquipAttrInProp().getType(); // 强化的属性种类

				// 查找准备强化的属性
				int minAttrValue = 0xffffff;
				MmochatEquipAttribute attrToStrenthen = null; // 准备强化的属性
				List<MmochatEquipAttribute> attrList = new ArrayList<MmochatEquipAttribute>();
				// 附加属性
				if (equip.getEquipRandAttr() != null
						&& equip.getEquipRandAttr().size() > 0) {
					attrList.addAll(equip.getEquipRandAttr());
				}
				// 粉属性
				if (equip.getEquipPinkAttr() != null) {
					attrList.add(equip.getEquipPinkAttr());
				}
				for (MmochatEquipAttribute attr : attrList) {
					if (attr != null && attr.getType() == attrTypeToStrenthen) {
						if (attr.getValue() < minAttrValue) {
							attrToStrenthen = attr;
							minAttrValue = attr.getValue();
						}
					}
				}
				if (attrToStrenthen == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备中没有<"
							+ attrTypeToStrenthen.toString() + ">属性，无法强化!");
				}

				// 开始强化
				Integer[] values = equipRandAttrData.get(equip.getEquipType())
						.get(attrToStrenthen.getType()).get(
								equip.getEquipTrueLevel());
				int maxValue = Math.max(values[0], values[1]);
				if (maxValue == attrToStrenthen.getValue()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备中<"
							+ attrTypeToStrenthen.toString()
							+ ">属性数值已达最大值，无法再强化!");
				}

				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除强化水晶
				int needNum = 1;
				for (MmochatPackageGrid grid : prop_strenthen) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.强化水晶, 1);
				// 属性数值重新生成
				int attrValue = 0;
				boolean success = false;
				if (MmochatUtil.isInPercent(strenthenEquipAttrRate)) {
					int oldAttrValue = attrToStrenthen.getValue();
					try {
						attrValue = MmochatUtil.getRandomValue(values[0],
								values[1]);
						if (attrValue > oldAttrValue) {
							success = true;
							attrToStrenthen.setValue(attrValue);
							gridNeedUpdate.add(equipGrid);
						} else {
							success = false;
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备强化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				String userMsg;
				if (success) {
					userMsg = MmochatUtil.wrapColor("恭喜!属性数值强化成功!"
							+ equip.getEquipLevelNeed() + "级<"
							+ attrTypeToStrenthen.toString() + ">属性最大值为"
							+ maxValue + "，当前值为" + attrToStrenthen.getValue()
							+ "!", Color.green);
				} else {
					userMsg = "强化失败!新生成的属性数值为" + attrValue
							+ "，不大于原数值，装备属性数值保持不变。";
					if (equip.getLife_turn() > 0) {
						userMsg += equip.getLife_turn() + "转";
					}
					userMsg += equip.getEquipLevelNeed() + "级<"
							+ attrTypeToStrenthen.toString() + ">属性最大值为"
							+ maxValue + "!";
					userMsg = MmochatUtil.wrapColor(userMsg, Color.red);
				}
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), userMsg);
			}
			case 首饰升级: {
				// 首饰+2块女娲石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "首饰升级需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_update = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.女娲石) {
							prop_update.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的首饰
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件首饰!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件首饰!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件首饰!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件首饰!");
				}
				if (equip.getEquipType() != MmochatEquipType.玉佩
						&& equip.getEquipType() != MmochatEquipType.手镯
						&& equip.getEquipType() != MmochatEquipType.挂坠) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交玉佩、手镯或挂坠!");
				}
				if (equip.getEquipRandAttr().size() >= MmochatConstant.maxExtraAttrNumOfJewelry) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此首饰已达顶级，无法再升级!");
				}
				// 检查女娲石：数量
				int num = 0;
				for (MmochatPackageGrid grid : prop_update) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 2) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交2块女娲石!");
				}

				// 开始升级
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除女娲石
				int needNum = 2;
				for (MmochatPackageGrid grid : prop_update) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.女娲石, 2);
				// 首饰升级，并增加一条随机属性
				int level = equip.getEquipLevelNeed();
				level = Math.min(level + 20, MmochatConstant.equipMaxLevel);
				equip.setEquipLevelNeed(level);
				equip.setEquipName(getEquipName(equip.getEquipType(), level));

				// 设置基础属性
				MmochatEquipType equipType = equip.getEquipType();
				int equipLevel = equip.getEquipLevelNeed();
				equip.getEquipBaseAttr().clear();
				List<MmochatEquipAttributeType> baseAttrType = getEquipAttributeTypes(
						equipType, MmochatEquipAttributeQualityType.基础属性);
				for (MmochatEquipAttributeType attrType : baseAttrType) {
					MmochatEquipAttribute attr = new MmochatEquipAttribute();
					attr.setType(attrType);
					attr.setValue(getEquipBaseAttrValue(equipType, equipLevel,
							attrType));
					equip.getEquipBaseAttr().add(attr);
				}

				List<MmochatEquipAttributeType> randAttrList = getEquipAttributeTypes(
						equip.getEquipType(),
						MmochatEquipAttributeQualityType.附加属性);
				for (MmochatEquipAttribute attr : equip.getEquipRandAttr()) {
					randAttrList.remove(attr.getType());
				}
				int sumPrority = 0;
				for (MmochatEquipAttributeType type1 : randAttrList) {
					sumPrority += type1.getPrority();
				}
				if (sumPrority > 0) {
					// 根据属性权值决定属性出现的机率
					int prority = MmochatUtil.getRandomValue(sumPrority);
					int curPrority = 0;
					MmochatEquipAttributeType attrType = null;
					for (MmochatEquipAttributeType type1 : randAttrList) {
						curPrority += type1.getPrority();
						if (curPrority > prority) {
							attrType = type1;
							break;
						}
					}
					if (attrType != null) {
						try {
							Map<MmochatEquipAttributeType, Map<Integer, Integer[]>> map1 = equipRandAttrData
									.get(equip.getEquipType());
							Map<Integer, Integer[]> map2 = map1.get(attrType);
							Integer[] values = map2.get(equip
									.getEquipLevelNeed());
							// Integer[] values = equipRandAttrData.get(
							// equip.getEquipType()).get(attrType).get(
							// equip.getEquipLevelNeed());
							int attrValue = MmochatUtil.getRandomValue(
									values[0], values[1]);
							MmochatEquipAttribute attr = new MmochatEquipAttribute();
							attr.setType(attrType);
							attr.setValue(attrValue);
							equip.addRandAttr(attr);
							gridNeedUpdate.add(equipGrid);
						} catch (Exception e) {
							e.printStackTrace();
						}
					} else {
						log.debug("attrType == null");
					}
				} else {
					log.debug("sumPrority <= 0");
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.首饰升级, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "首饰升级成功!");
			}
			case 装备升级: {
				// 装备+2块升级石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备升级需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_update = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.升级石) {
							prop_update.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交武器、头盔、衣服或鞋子!");
				}
				if (equip.getEquipLevelNeed() >= MmochatConstant.equipMaxLevel) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备已达顶级，无法再升级!");
				}
				int curExtraLevel = equip.getEquipExtraLevel();
				if (curExtraLevel < 0 || curExtraLevel >= 10) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备附加等级异常，请联系客服解决!");
				}
				// 检查升级石：数量
				int num = 0;
				for (MmochatPackageGrid grid : prop_update) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 2) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交2块升级石!");
				}

				// 开始升级
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除升级石
				int needNum = 2;
				for (MmochatPackageGrid grid : prop_update) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.升级石, 2);
				// 装备升级
				String retInfo;
				int rate = equipUplevelRate[curExtraLevel];
				if (MmochatUtil.isInPercent(rate)) {
					// 升级成功
					gridNeedUpdate.add(equipGrid);
					equip.addEquipExtraLevel(1);
					if (equip.getEquipExtraLevel() >= 10) {
						// 完成升级，重新设置数值
						retInfo = "恭喜!装备升级成功，装备数值已经提升。";
						// 等级、equipExtraLevel、
						// 基础属性、改造属性、附加属性、粉属性、套装明属性、套装暗属性
						int oldEquipLevel = equip.getEquipLevelNeed();
						equip.addEquipLevelNeed(10);
						equip.addEquipExtraLevel(-10);
						equip.setEquipName(getEquipName(equip.getEquipType(),
								equip.getEquipLevelNeed()));

						// 设置基础属性
						MmochatEquipType equipType = equip.getEquipType();
						int equipLevel = equip.getEquipLevelNeed();
						equip.getEquipBaseAttr().clear();
						List<MmochatEquipAttributeType> baseAttrType = getEquipAttributeTypes(
								equipType,
								MmochatEquipAttributeQualityType.基础属性);
						for (MmochatEquipAttributeType attrType : baseAttrType) {
							MmochatEquipAttribute attr = new MmochatEquipAttribute();
							attr.setType(attrType);
							attr.setValue(getEquipBaseAttrValue(equipType,
									equipLevel, attrType));
							equip.getEquipBaseAttr().add(attr);
						}
						// 设置改造属性
						int equipModifyLevel = equip.getEquipModifyLevel();
						if (equipModifyLevel != 0) {
							equip.setEquipModifyLevel(0);
							equip.setEquipModifyLevel(equipModifyLevel);
						}
						// 设置附加属性
						for (MmochatEquipAttribute attr : equip
								.getEquipRandAttr()) {
							Integer[] values = equipRandAttrData.get(
									equip.getEquipType()).get(attr.getType())
									.get(oldEquipLevel);
							int maxValue = Math.max(values[0], values[1]);
							int minValue = Math.min(values[0], values[1]);
							double valuePercent;
							if (maxValue == minValue) {
								valuePercent = 1;
							} else {
								valuePercent = 1.0
										* (attr.getValue() - minValue)
										/ (maxValue - minValue);
							}
							Integer[] newValues = equipRandAttrData.get(
									equip.getEquipType()).get(attr.getType())
									.get(equip.getEquipLevelNeed());
							maxValue = Math.max(newValues[0], newValues[1]);
							minValue = Math.min(newValues[0], newValues[1]);
							int newValue = (int) (minValue + (maxValue - minValue)
									* valuePercent);
							attr.setValue(newValue);
						}
						// 设置粉属性
						{
							MmochatEquipAttribute attr = equip
									.getEquipPinkAttr();
							if (attr != null) {
								Integer[] values = equipRandAttrData.get(
										equip.getEquipType()).get(
										attr.getType()).get(oldEquipLevel);
								int maxValue = Math.max(values[0], values[1]);
								int minValue = Math.min(values[0], values[1]);
								double valuePercent;
								if (maxValue == minValue) {
									valuePercent = 1;
								} else {
									valuePercent = 1.0
											* (attr.getValue() - minValue)
											/ (maxValue - minValue);
								}
								Integer[] newValues = equipRandAttrData.get(
										equip.getEquipType()).get(
										attr.getType()).get(
										equip.getEquipLevelNeed());
								maxValue = Math.max(newValues[0], newValues[1]);
								minValue = Math.min(newValues[0], newValues[1]);
								int newValue = (int) (minValue + (maxValue - minValue)
										* valuePercent);
								attr.setValue(newValue);
							}
						}
						// 套装明属性
						{
							MmochatEquipAttribute attr = equip
									.getEquipGreenLightAttr();
							if (attr != null) {
								Integer[] values = greenEquipLightAttrData.get(
										equip.getEquipType()).get(
										attr.getType()).get(oldEquipLevel);
								int maxValue = Math.max(values[0], values[1]);
								int minValue = Math.min(values[0], values[1]);
								double valuePercent;
								if (maxValue == minValue) {
									valuePercent = 1;
								} else {
									valuePercent = 1.0
											* (attr.getValue() - minValue)
											/ (maxValue - minValue);
								}
								Integer[] newValues = greenEquipLightAttrData
										.get(equip.getEquipType()).get(
												attr.getType()).get(
												equip.getEquipLevelNeed());
								maxValue = Math.max(newValues[0], newValues[1]);
								minValue = Math.min(newValues[0], newValues[1]);
								int newValue = (int) (minValue + (maxValue - minValue)
										* valuePercent);
								attr.setValue(newValue);
							}
						}
						// 套装暗属性
						{
							MmochatEquipAttribute attr = equip
									.getEquipGreenDarkAttr();
							if (attr != null) {
								Integer[] values = greenEquipDarkAttrData.get(
										equip.getEquipType()).get(
										attr.getType()).get(oldEquipLevel);
								int maxValue = Math.max(values[0], values[1]);
								int minValue = Math.min(values[0], values[1]);
								double valuePercent;
								if (maxValue == minValue) {
									valuePercent = 1;
								} else {
									valuePercent = 1.0
											* (attr.getValue() - minValue)
											/ (maxValue - minValue);
								}
								Integer[] newValues = greenEquipDarkAttrData
										.get(equip.getEquipType()).get(
												attr.getType()).get(
												equip.getEquipLevelNeed());
								maxValue = Math.max(newValues[0], newValues[1]);
								minValue = Math.min(newValues[0], newValues[1]);
								int newValue = (int) (minValue + (maxValue - minValue)
										* valuePercent);
								attr.setValue(newValue);
							}
						}
					} else {
						retInfo = "恭喜!装备升级成功，在提升10级前，装备数值保持不变。";
					}
				} else {
					// 升级失败
					if (curExtraLevel >= 6) {
						// 回退1级
						gridNeedUpdate.add(equipGrid);
						equip.addEquipExtraLevel(-1);
						retInfo = "装备升级失败!由于当前提升等级超过5级，失败时装备等级降低了1级。";
					} else {
						retInfo = "装备升级失败!";
					}
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备升级, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), retInfo);
			}
			case 装备法宝认主: {
				// 装备
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备法宝认主需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备
							|| obj.getObjectType() == MmochatObjectType.法宝) {
						equipList.add(grid);
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件装备或一件法宝!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交一件装备或一件法宝!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件装备或一件法宝!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交一件装备或一件法宝!");
				}
				if (equip.getOwnerState() == MmochatObjOwnerState.已认主) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此物品已经认主，无须再认主!");
				}
				if (equip.getBorrowFromRoleId() != null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此物品是借来的，无法认主!");
				}

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 装备认主
				MmochatObjOwnerState oldState = equip.getOwnerState();
				equip.setOwnerState(MmochatObjOwnerState.已认主);
				gridNeedUpdate.add(equipGrid);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					equip.setOwnerState(oldState);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备认主, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(),
						"此物品认主成功!绑定后无法交易、遗弃或回收。");
			}
			case 装备法宝解除认主: {
				// 装备
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备或法宝解除认主需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备
							|| obj.getObjectType() == MmochatObjectType.法宝) {
						equipList.add(grid);
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备或法宝!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交一件装备或法宝!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备或法宝!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备或法宝!");
				}
				if (equip.getOwnerState() == MmochatObjOwnerState.未认主) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此物品未认主，无须解除认主!");
				}
				if (equip.getOwnerState() == MmochatObjOwnerState.解除认主中) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此物品正在解除认主中，无须再次解除!");
				}
				if (equip.getBorrowFromRoleId() != null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此物品是借来的，无法解除认主!");
				}

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 装备解除认主
				MmochatObjOwnerState oldState = equip.getOwnerState();
				equip.setOwnerState(MmochatObjOwnerState.解除认主中);
				equip.setReleaseOwnerStartTime(System.currentTimeMillis());
				gridNeedUpdate.add(equipGrid);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					equip.setOwnerState(oldState);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备解除认主, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(
						req.getHallState(),
						"此物品解除认主中，"
								+ (MmochatConstant.releaseOwnerInterval / MmochatConstant.MS_PER_DAY)
								+ "天后正式解除认主。在此期间，您只要再次对其进行认主，就可以中断解除认主操作。");

			}
			case 装备绑定: {
				// 装备
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备绑定需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.isBind()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备已经绑定，无须再绑定!");
				}

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 装备绑定
				equip.setBind(true);
				gridNeedUpdate.add(equipGrid);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					equip.setBind(false);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备绑定, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(),
						"此装备绑定成功!绑定后无法遗弃。");
			}
			case 装备解除绑定: {

				// 装备
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备解除绑定需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (!equip.isBind()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备未绑定，无须解除绑定!");
				}
				if (equip.getBorrowFromRoleId() != null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备是借来的，无法解除绑定!");
				}

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 装备绑定
				equip.setBind(false);
				gridNeedUpdate.add(equipGrid);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					equip.setBind(false);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备解除绑定, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "此装备解除绑定成功!");

			}
			case 转生装备进化: {
				// 一件装备+4块升级石+8块进化石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备进化需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				MmochatPropType lifeTurnPropType = null;
				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_update = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_lifeTurn = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				// 读取装备信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					}
				}
				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交武器、头盔、衣服或鞋子!");
				}
				if (equip.getEquipLevelNeed() != MmochatConstant.equipLifeTurnLevelNeed) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交"
							+ MmochatConstant.equipLifeTurnLevelNeed + "级装备!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.绿装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交绿装备!");
				}
				if (equip.getLife_turn() >= MmochatConstant.maxLifeTurn) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备已达最大转生次数，无法再进化!");
				}

				int equipLifeTurn = equip.getLife_turn(); // 当前装备的转生次数
				if (equipLifeTurn >= me.getLife_turn()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的修为尚不足以进化此装备，此装备需要人物" + (equipLifeTurn + 1)
									+ "转后才能进化。");
				}
				switch (equipLifeTurn + 1) {
				case 1:
					lifeTurnPropType = MmochatPropType.一转进化石;
					break;
				case 2:
					lifeTurnPropType = MmochatPropType.二转进化石;
					break;
				case 3:
					lifeTurnPropType = MmochatPropType.三转进化石;
					break;
				case 4:
					lifeTurnPropType = MmochatPropType.四转进化石;
					break;
				case 5:
					lifeTurnPropType = MmochatPropType.五转进化石;
					break;
				case 6:
					lifeTurnPropType = MmochatPropType.六转进化石;
					break;
				case 7:
					lifeTurnPropType = MmochatPropType.七转进化石;
					break;
				case 8:
					lifeTurnPropType = MmochatPropType.八转进化石;
					break;
				case 9:
					lifeTurnPropType = MmochatPropType.九转进化石;
					break;
				default:
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此装备异常，请联系在线客服进行修复。");
				}

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.升级石) {
							prop_update.add(grid);
						} else if (obj.getPropType() == lifeTurnPropType) {
							prop_lifeTurn.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查升级石：数量
				int num = 0;
				for (MmochatPackageGrid grid : prop_update) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 4) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交4块升级石!");
				}

				// 检查进化石：数量
				num = 0;
				for (MmochatPackageGrid grid : prop_lifeTurn) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 8) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交8块"
							+ lifeTurnPropType.toString() + "!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始进化
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除升级石
				int needNum = 4;
				for (MmochatPackageGrid grid : prop_update) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 扣除进化石
				needNum = 8;
				for (MmochatPackageGrid grid : prop_lifeTurn) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.升级石, 4);
				MmochatStatisticsService.addPropCost(lifeTurnPropType, 8);

				// 装备进化
				String retInfo;

				int oldEquipTrueLevel = equip.getEquipTrueLevel();

				gridNeedUpdate.add(equipGrid);
				equip.addLife_turn(1);
				equip.setSecond_role_type(me.getSecond_role_type());

				// 完成升级，重新设置数值
				retInfo = "恭喜!装备进化成功，装备数值得到了提升。";

				// 设置基础属性
				MmochatEquipType equipType = equip.getEquipType();
				int equipLevel = equip.getEquipTrueLevel();
				equip.getEquipBaseAttr().clear();
				List<MmochatEquipAttributeType> baseAttrType = getEquipAttributeTypes(
						equipType, MmochatEquipAttributeQualityType.基础属性);
				for (MmochatEquipAttributeType attrType : baseAttrType) {
					MmochatEquipAttribute attr = new MmochatEquipAttribute();
					attr.setType(attrType);
					attr.setValue(getEquipBaseAttrValue(equipType, equipLevel,
							attrType));
					equip.getEquipBaseAttr().add(attr);
				}
				// 设置改造属性
				int equipModifyLevel = equip.getEquipModifyLevel();
				if (equipModifyLevel != 0) {
					equip.setEquipModifyLevel(0);
					equip.setEquipModifyLevel(equipModifyLevel);
				}
				// 设置附加属性
				for (MmochatEquipAttribute attr : equip.getEquipRandAttr()) {
					Integer[] values = equipRandAttrData.get(
							equip.getEquipType()).get(attr.getType()).get(
							oldEquipTrueLevel);
					int maxValue = Math.max(values[0], values[1]);
					int minValue = Math.min(values[0], values[1]);
					double valuePercent;
					if (maxValue == minValue) {
						valuePercent = 1;
					} else {
						valuePercent = 1.0 * (attr.getValue() - minValue)
								/ (maxValue - minValue);
					}
					Integer[] newValues = equipRandAttrData.get(
							equip.getEquipType()).get(attr.getType()).get(
							equip.getEquipTrueLevel());
					maxValue = Math.max(newValues[0], newValues[1]);
					minValue = Math.min(newValues[0], newValues[1]);
					int newValue = (int) (minValue + (maxValue - minValue)
							* valuePercent);
					attr.setValue(newValue);
				}
				// 设置粉属性
				{
					MmochatEquipAttribute attr = equip.getEquipPinkAttr();
					if (attr != null) {
						Integer[] values = equipRandAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								oldEquipTrueLevel);
						int maxValue = Math.max(values[0], values[1]);
						int minValue = Math.min(values[0], values[1]);
						double valuePercent;
						if (maxValue == minValue) {
							valuePercent = 1;
						} else {
							valuePercent = 1.0 * (attr.getValue() - minValue)
									/ (maxValue - minValue);
						}
						Integer[] newValues = equipRandAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								equip.getEquipTrueLevel());
						maxValue = Math.max(newValues[0], newValues[1]);
						minValue = Math.min(newValues[0], newValues[1]);
						int newValue = (int) (minValue + (maxValue - minValue)
								* valuePercent);
						attr.setValue(newValue);
					}
				}
				// 套装明属性
				{
					MmochatEquipAttribute attr = equip.getEquipGreenLightAttr();
					if (attr != null) {
						Integer[] values = greenEquipLightAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								oldEquipTrueLevel);
						int maxValue = Math.max(values[0], values[1]);
						int minValue = Math.min(values[0], values[1]);
						double valuePercent;
						if (maxValue == minValue) {
							valuePercent = 1;
						} else {
							valuePercent = 1.0 * (attr.getValue() - minValue)
									/ (maxValue - minValue);
						}
						Integer[] newValues = greenEquipLightAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								equip.getEquipTrueLevel());
						maxValue = Math.max(newValues[0], newValues[1]);
						minValue = Math.min(newValues[0], newValues[1]);
						int newValue = (int) (minValue + (maxValue - minValue)
								* valuePercent);
						attr.setValue(newValue);
					}
				}
				// 套装暗属性
				{
					MmochatEquipAttribute attr = equip.getEquipGreenDarkAttr();
					if (attr != null) {
						Integer[] values = greenEquipDarkAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								oldEquipTrueLevel);
						int maxValue = Math.max(values[0], values[1]);
						int minValue = Math.min(values[0], values[1]);
						double valuePercent;
						if (maxValue == minValue) {
							valuePercent = 1;
						} else {
							valuePercent = 1.0 * (attr.getValue() - minValue)
									/ (maxValue - minValue);
						}
						Integer[] newValues = greenEquipDarkAttrData.get(
								equip.getEquipType()).get(attr.getType()).get(
								equip.getEquipTrueLevel());
						maxValue = Math.max(newValues[0], newValues[1]);
						minValue = Math.min(newValues[0], newValues[1]);
						int newValue = (int) (minValue + (maxValue - minValue)
								* valuePercent);
						attr.setValue(newValue);
					}
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备进化, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), retInfo);

			}
			case 装备仙魔互转: {
				// 一件转生装备、1块仙魔转换石、4块未吸附属性的(超级)白水晶
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "装备仙魔互转需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_shuijin = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_xianmo = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.装备) {
						equipList.add(grid);
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.白水晶
								|| obj.getPropType() == MmochatPropType.超级白水晶) {
							if (obj.getEquipAttrInProp() == null) {
								prop_shuijin.add(grid);
							} else {
								other.add(grid);
							}
						} else if (obj.getPropType() == MmochatPropType.仙魔转换石) {
							prop_xianmo.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查提交的装备
				if (equipList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equipList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一件装备!");
				}
				MmochatPackageGrid equipGrid = equipList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				MmochatCommonObject equip = equipGrid.getObject();
				if (equip == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一件装备!");
				}
				if (equip.getEquipType() != MmochatEquipType.武器
						&& equip.getEquipType() != MmochatEquipType.头盔
						&& equip.getEquipType() != MmochatEquipType.衣服
						&& equip.getEquipType() != MmochatEquipType.鞋子) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"只能提交武器、头盔、衣服或鞋子!");
				}
				if (equip.getEquipLevelNeed() != MmochatConstant.equipLifeTurnLevelNeed) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交"
							+ MmochatConstant.equipLifeTurnLevelNeed + "级装备!");
				}
				if (equip.getEquipQuality() != MmochatEquipQualityType.绿装) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交绿装备!");
				}
				if (equip.getLife_turn() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交转生装备!");
				}

				int equipLifeTurn = equip.getLife_turn(); // 当前装备的转生次数
				if (equipLifeTurn > me.getLife_turn()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的修为尚不足以转换此装备，此装备需要人物" + equipLifeTurn + "转后才能转换。");
				}
				if (equip.getSecond_role_type() == MmochatSecondRoleType.未转生) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交转生装备!");
				}

				// 检查白水晶：数量
				int num = 0;
				for (MmochatPackageGrid grid : prop_shuijin) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 4) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交4块白水晶!");
				}

				// 检查仙魔转换石：数量
				num = 0;
				for (MmochatPackageGrid grid : prop_xianmo) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1块仙魔转换石!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始转换
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除白水晶
				int needNum = 4;
				for (MmochatPackageGrid grid : prop_shuijin) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 扣除转换石
				needNum = 1;
				for (MmochatPackageGrid grid : prop_xianmo) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
				MmochatStatisticsService.addPropCost(MmochatPropType.白水晶, 4);
				MmochatStatisticsService.addPropCost(MmochatPropType.仙魔转换石, 1);

				// 装备转换
				String retInfo;

				gridNeedUpdate.add(equipGrid);
				if (equip.getSecond_role_type() == MmochatSecondRoleType.仙道) {
					equip.setSecond_role_type(MmochatSecondRoleType.魔道);
				} else if (equip.getSecond_role_type() == MmochatSecondRoleType.魔道) {
					equip.setSecond_role_type(MmochatSecondRoleType.仙道);
				}

				// 完成升级，重新设置数值
				retInfo = "恭喜!装备转换成功。";

				// 设置改造属性
				int equipModifyLevel = equip.getEquipModifyLevel();
				if (equipModifyLevel != 0) {
					equip.setEquipModifyLevel(0);
					equip.setEquipModifyLevel(equipModifyLevel);
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.装备仙魔转换, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), retInfo);

			}
			case 龙年大礼包合成: {
				// 龙年大吉o龙、龙年大吉o年、龙年大吉o大、龙年大吉o吉
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "龙年大礼包合成需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop2 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop3 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop4 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.龙年大吉o龙) {
							prop1.add(grid);
						} else if (obj.getPropType() == MmochatPropType.龙年大吉o年) {
							prop2.add(grid);
						} else if (obj.getPropType() == MmochatPropType.龙年大吉o大) {
							prop3.add(grid);
						} else if (obj.getPropType() == MmochatPropType.龙年大吉o吉) {
							prop4.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查道具数量
				int num = 0;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<龙年大吉o龙>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<龙年大吉o年>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop3) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<龙年大吉o大>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop4) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<龙年大吉o吉>道具!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				if (!me.hasEnoughPackageSpace(1)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的包裹太满，请至少留出1个空位，以免礼物掉落。");
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除道具
				int needNum = 1;
				for (MmochatPackageGrid grid : prop1) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop2) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop3) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop4) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 道具合成
				MmochatProp prop = new MmochatProp(MmochatPropType.龙年大礼包);
				me.addObjectToPackage(prop);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.龙年大礼包合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!您合成了龙年大礼包。");
			}
			case 元宵节礼包合成: {
				// 庆元宵o庆、庆元宵o元、庆元宵o宵
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "元宵节礼包合成需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop2 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop3 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.庆元宵o庆) {
							prop1.add(grid);
						} else if (obj.getPropType() == MmochatPropType.庆元宵o元) {
							prop2.add(grid);
						} else if (obj.getPropType() == MmochatPropType.庆元宵o宵) {
							prop3.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查道具数量
				int num = 0;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<庆元宵o庆>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<庆元宵o元>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop3) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<庆元宵o宵>道具!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				if (!me.hasEnoughPackageSpace(1)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的包裹太满，请至少留出1个空位，以免礼物掉落。");
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除道具
				int needNum = 1;
				for (MmochatPackageGrid grid : prop1) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop2) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop3) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 道具合成
				MmochatProp prop = new MmochatProp(MmochatPropType.元宵节礼包);
				me.addObjectToPackage(prop);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.元宵节礼包合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!您合成了元宵节礼包。");
			}
			case 新年礼物合成: {
				// 新年快乐o新、新年快乐o年、新年快乐o快、新年快乐o乐
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "新年礼物合成需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop2 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop3 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop4 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.新年快乐o新) {
							prop1.add(grid);
						} else if (obj.getPropType() == MmochatPropType.新年快乐o年) {
							prop2.add(grid);
						} else if (obj.getPropType() == MmochatPropType.新年快乐o快) {
							prop3.add(grid);
						} else if (obj.getPropType() == MmochatPropType.新年快乐o乐) {
							prop4.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查道具数量
				int num = 0;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<新年快乐o新>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<新年快乐o年>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop3) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<新年快乐o快>道具!");
				}

				num = 0;
				for (MmochatPackageGrid grid : prop4) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				if (num < 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个<新年快乐o乐>道具!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				if (!me.hasEnoughPackageSpace(1)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的包裹太满，请至少留出1个空位，以免礼物掉落。");
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除道具
				int needNum = 1;
				for (MmochatPackageGrid grid : prop1) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop2) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop3) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				needNum = 1;
				for (MmochatPackageGrid grid : prop4) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 道具合成
				MmochatProp prop = new MmochatProp(MmochatPropType.新年大礼包);
				me.addObjectToPackage(prop);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.新年礼物合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!您合成了新年大礼包。");
			}
			case 武魂石升级: {
				// 1块武魂石、若干武魂石灵气丹或武魂石灵气池
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂石升级需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop2 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop3 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.武魂石) {
							prop1.add(grid);
						} else if (obj.getPropType() == MmochatPropType.武魂石灵气丹) {
							prop2.add(grid);
						} else if (obj.getPropType() == MmochatPropType.武魂石灵气池) {
							prop3.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查道具数量
				int num = 0;
				MmochatPackageGrid targetGrid = null;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
						if (grid.getObject().getPkStoneAttr() != null) {
							targetGrid = grid;
						}
					}
				}
				if (num != 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1个武魂石!");
				}
				if (targetGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个已鉴定出技能的武魂石!");
				}
				MmochatCommonObject targetObj = targetGrid.getObject();
				if (targetObj == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个已鉴定出技能的武魂石!");
				}

				if (targetObj.getPropLevel() >= targetObj.getLevelLimit()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"您的武魂石等级已达上限，无法继续升级!");
				}

				int num1 = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						num1 += grid.getObject().getOverlapNum();
					}
				}

				int num2 = 0;
				for (MmochatPackageGrid grid : prop3) {
					if (grid.getObject() != null) {
						num2 += grid.getObject().getOverlapNum();
					}
				}
				if (num1 + num2 == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交武魂石灵气丹或武魂石灵气池!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				gridNeedUpdate.add(targetGrid);

				// 扣除道具
				int addExp = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						addExp += grid.getObject().getOverlapNum()
								* MmochatConstant.expInPkStoneExpBadBall;
						grid.setObject(null);
						gridNeedUpdate.add(grid);
					}
				}
				for (MmochatPackageGrid grid : prop3) {
					if (grid.getObject() != null) {
						addExp += grid.getObject().getOverlapNum()
								* MmochatConstant.expInPkStoneExpGoodBall;
						grid.setObject(null);
						gridNeedUpdate.add(grid);
					}
				}

				targetObj.addExp(addExp);
				int uplevelExp = MmochatPkMachineService
						.getUplevelExpForPkStone(targetObj.getPropLevel());
				String hint = "";
				boolean uplevel = false;
				while (targetObj.getExp() >= uplevelExp) {
					if (targetObj.getPropLevel() < targetObj.getLevelLimit()) {
						targetObj.addExp(-1 * uplevelExp);
						targetObj.addPropLevel(1);

						// 重新设置基础数值
						MmochatEquipAttribute attr = targetObj
								.getPkStoneBaseAttr();
						int newValue = MmochatPkMachineService
								.getPkStoneBaseAttrValueByLevel(attr.getType(),
										targetObj.getPropLevel());
						attr.setValue(newValue);

						// 重新设置技能数值
						MmochatEquipAttribute attr1 = targetObj
								.getPkStoneAttr();
						int newValue1 = MmochatPkMachineService
								.getPkStoneSkillValueByLevel(attr1.getType(),
										targetObj.getPropLevel());
						attr1.setValue(newValue1);
						uplevel = true;
					} else {
						// 等级达上限
						if (targetObj.getLevelLimit() >= MmochatConstant.pkStoneMaxLevel) {
							hint = "您的武魂石等级已达极限，无法继续升级!";
						} else {
							hint = "您的武魂石等级已达上限!需要先提升等级上限，才能继续升级。";
						}
						break;
					}
					uplevelExp = MmochatPkMachineService
							.getUplevelExpForPkStone(targetObj.getPropLevel());
				}

				if (uplevel) {
					hint = "您的武魂石升级了，基础类型数值提升了，"
							+ "技能数值只在6级、11级、16级、21级、26级、31级、36级时提升!";
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.升级武魂石, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!您的武魂石获得了"
						+ addExp + "点灵气!" + hint);
			}
			case 武魂石等级上限突破: {
				// 1块武魂石、若干武魂突破石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂石等级上限突破需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop2 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.武魂石) {
							prop1.add(grid);
						} else if (obj.getPropType() == MmochatPropType.武魂突破石) {
							prop2.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();

				// 检查道具数量
				int num = 0;
				MmochatPackageGrid targetGrid = null;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
						if (grid.getObject().getPkStoneAttr() != null) {
							targetGrid = grid;
						}
					}
				}
				if (num != 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1个武魂石!");
				}
				if (targetGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个已鉴定出技能的武魂石!");
				}
				MmochatCommonObject targetObj = targetGrid.getObject();
				if (targetObj == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个已鉴定出技能的武魂石!");
				}
				if (targetObj.getLevelLimit() >= MmochatConstant.pkStoneMaxLevel) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此武魂石等级上限已达最大值，不能再突破!");
				}
				int needPropNum = pkStoneUplevelNum[targetObj.getLevelLimit()];

				int num1 = 0;
				for (MmochatPackageGrid grid : prop2) {
					if (grid.getObject() != null) {
						num1 += grid.getObject().getOverlapNum();
					}
				}

				if (num1 < needPropNum) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "当前武魂石等级上限为"
							+ targetObj.getLevelLimit() + "级，继续突破上限需要提交"
							+ needPropNum + "块武魂突破石!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				gridNeedUpdate.add(targetGrid);

				// 扣除道具
				int needNum = needPropNum;
				for (MmochatPackageGrid grid : prop2) {
					MmochatCommonObject obj1 = grid.getObject();
					if (obj1 != null) {
						if (obj1.getOverlapNum() > needNum) {
							obj1.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj1.getOverlapNum();
							obj1.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}

				// 等级上限加1
				int newLevel = Math.min(targetObj.getLevelLimit() + 1,
						MmochatConstant.pkStoneMaxLevel);
				targetObj.setLevelLimit(newLevel);

				String hint = "您的武魂石等级上限提升到" + newLevel + "级了!";

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.升级武魂石, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!" + hint);

			}
			case 武魂技能镶嵌: {
				// 1个武魂、若干武魂石
				int modifyPrice = MmochatConstant.getModifyEquipPrice();
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂技能镶嵌需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> pkMachineList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> prop_stone = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.法宝) {
						if (obj.getSuperMachineType() == MmochatSuperMachineType.武魂) {
							pkMachineList.add(grid);
						} else {
							other.add(grid);
						}
					} else if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.武魂石
								&& obj.getPkStoneAttr() != null) {
							prop_stone.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"提交的物品不正确!只能提交1个武魂、若干已鉴定出技能的武魂石!");
				}
				// 检查提交的法宝
				if (pkMachineList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一个武魂!");
				}
				if (pkMachineList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交一个武魂!");
				}
				MmochatPackageGrid equipGrid = pkMachineList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一个武魂!");
				}
				MmochatCommonObject pkMachine = equipGrid.getObject();
				if (pkMachine == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交一个武魂!");
				}
				gridNeedUpdate.add(equipGrid);

				int curSkillNum = pkMachine.getPkMachineSkills().size();// 当前技能数
				int maxSkillNum = pkMachine.getPkMachineStar();// 最多镶嵌数

				if (curSkillNum + prop_stone.size() > maxSkillNum) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "此武魂最多可镶嵌"
							+ maxSkillNum + "个武魂石!");
				}

				// 基础属性类型必需相同
				MmochatEquipAttributeType baseAttrType = null;

				// 同类属性不能出现2个
				Map<MmochatEquipAttributeType, MmochatEquipAttribute> attrMap = new HashMap<MmochatEquipAttributeType, MmochatEquipAttribute>();
				// 武魂中已经存在的属性
				for (MmochatCommonObject o : pkMachine.getPkMachineSkills()) {
					if (o != null && o.getPkStoneAttr() != null) {
						attrMap.put(o.getPkStoneAttr().getType(), o
								.getPkStoneAttr());
						baseAttrType = o.getPkStoneBaseAttr().getType();
					}
				}
				for (MmochatPackageGrid grid : prop_stone) {
					if (grid == null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请放入鉴定出技能的武魂石!");
					}
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"请放入鉴定出技能的武魂石!");
					}

					if (baseAttrType == null) {
						baseAttrType = obj.getPkStoneBaseAttr().getType();
					} else if (baseAttrType != obj.getPkStoneBaseAttr()
							.getType()) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"武魂中镶嵌的所有武魂石，其"
										+ MmochatUtil.wrapColor("基础类型",
												Color.green) + "必需相同!");
					}

					if (attrMap.get(obj.getPkStoneAttr().getType()) != null) {
						me.unLockState();
						return new Mmochat_14_12S(req.getHallState(),
								"武魂中不能同时存在2个相同类型的技能!");
					} else {
						attrMap.put(obj.getPkStoneAttr().getType(), obj
								.getPkStoneAttr());
					}
				}

				// 开始合成
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 扣除武魂石，加到武魂中
				for (MmochatPackageGrid grid : prop_stone) {
					if (grid.getObject() != null) {
						pkMachine.getPkMachineSkills().add(grid.getObject());
						grid.setObject(null);
						gridNeedUpdate.add(grid);
					}
				}

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.武魂技能合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "武魂技能镶嵌成功!");
			}
			case 武魂技能分离: {
				// 1个武魂
				int modifyPrice = MmochatConstant.seperatePkStonePrice;
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂技能分离需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}
				List<MmochatPackageGrid> pkMachineList = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.法宝) {
						if (obj.getSuperMachineType() == MmochatSuperMachineType.武魂) {
							pkMachineList.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
				}
				// 检查提交的装备
				if (pkMachineList.size() == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1个武魂!");
				}
				if (pkMachineList.size() > 1) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "只能提交1个武魂!");
				}
				MmochatPackageGrid equipGrid = pkMachineList.get(0);
				if (equipGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1个武魂!");
				}
				MmochatCommonObject pkMachine = equipGrid.getObject();
				if (pkMachine == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请提交1个武魂!");
				}
				int stoneNum = pkMachine.getPkMachineSkills().size();
				if (stoneNum == 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"此武魂中没有技能，无法分离!");
				}

				if (!me.hasEnoughPackageSpace(stoneNum)) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "请保留至少"
							+ stoneNum + "个包裹空位!");
				}

				// 开始分离属性
				// 备份
				Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
						.deepClone(
								me.getMyPackage(),
								new TypeToken<Map<Integer, MmochatPackageGrid>>() {
								}.getType());

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				gridNeedUpdate.add(equipGrid);

				for (MmochatCommonObject stone : pkMachine.getPkMachineSkills()) {
					if (stone != null) {
						gridNeedUpdate.addAll(me.addObjectToPackage(stone,
								false));
					}
				}
				pkMachine.getPkMachineSkills().clear();

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					me.setMyPackage(packageBak);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.武魂技能分离, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.setGrids(gridNeedUpdate);
				MmochatUtil.sendCommonPack(me, pack);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(),
						"武魂技能分离成功!技能已经以武魂石形式放到您的包裹!");

			}
			case 武魂石合成: {
				// 4块武魂石(已鉴定)
				int modifyPrice = MmochatConstant.checkPkStonePrice;
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂石合成需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.武魂石) {
							prop1.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				// 检查道具数量
				int num = 0;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						if (grid.getObject().getPkStoneAttr() != null) {
							num += grid.getObject().getOverlapNum();
						} else {
							me.unLockState();
							return new Mmochat_14_12S(req.getHallState(),
									"只能提交鉴定过的武魂石!");
						}
					}
				}
				if (num != 4) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交4个已鉴定的武魂石!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始合成

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 随机生成等级
				MmochatProp targetObj = new MmochatProp(MmochatPropType.武魂石);
				int level;
				if (MmochatUtil.isInPercent(99)) {
					level = 1;
				} else if (MmochatUtil.isInPercent(99)) {
					level = 2;
				} else {
					level = 3;
				}
				targetObj.setLevelLimit(MmochatConstant.pkStoneInitLevelLimit);
				targetObj.setPropLevel(level);

				// 随机生成基础类型
				MmochatEquipAttributeType baseAttrType = MmochatPkMachineService
						.getPkStoneRandBaseAttr();
				MmochatEquipAttribute attr = new MmochatEquipAttribute();
				attr.setType(baseAttrType);
				attr.setValue(MmochatPkMachineService
						.getPkStoneBaseAttrValueByLevel(baseAttrType, targetObj
								.getPropLevel()));
				targetObj.setPkStoneBaseAttr(attr);

				// 随机生成技能
				MmochatEquipAttributeType randAttrType = MmochatPkMachineService
						.getPkStoneRandAttr();
				MmochatEquipAttribute attr1 = new MmochatEquipAttribute();
				attr1.setType(randAttrType);
				attr1.setValue(MmochatPkMachineService
						.getPkStoneSkillValueByLevel(randAttrType, targetObj
								.getPropLevel()));
				targetObj.setPkStoneAttr(attr1);

				// 删除4个武魂石
				for (MmochatPackageGrid grid : prop1) {
					grid.setObject(null);
				}
				List<MmochatPackageGrid> grids = me.addObjectToPackage(targetObj, false);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();					
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.武魂石合成, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.addGrid(prop1);
				pack.addGrid(grids);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!武魂石合成成功。");
			}
			case 武魂石鉴定: {
				// 1块武魂石(未鉴定)
				int modifyPrice = MmochatConstant.checkPkStonePrice;
				if (me.getSmall_money() < modifyPrice) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "武魂石鉴定需要"
							+ MmochatUtil.getColorMoney(modifyPrice)
							+ "文钱，您的金钱不够!");
				}

				List<MmochatPackageGrid> prop1 = new ArrayList<MmochatPackageGrid>();
				List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();

				// 读取其它物品信息
				for (MmochatPackageGrid grid : objs) {
					MmochatCommonObject obj = grid.getObject();
					if (obj == null) {
						continue;
					}
					if (obj.getObjectType() == MmochatObjectType.道具) {
						if (obj.getPropType() == MmochatPropType.武魂石) {
							prop1.add(grid);
						} else {
							other.add(grid);
						}
					} else {
						other.add(grid);
					}
				}
				// 检查道具数量
				MmochatPackageGrid propGrid = null;
				int num = 0;
				for (MmochatPackageGrid grid : prop1) {
					if (grid.getObject() != null) {
						if (grid.getObject().getPkStoneAttr() == null) {
							num += grid.getObject().getOverlapNum();
							propGrid = grid;
						}
					}
				}
				if (num != 1 || propGrid == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个未鉴定的武魂石!");
				}
				MmochatCommonObject targetObj = propGrid.getObject();
				if (targetObj == null) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交1个未鉴定的武魂石!");
				}

				// 检查是否有其它物品
				if (other.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请不要提交其它无关物品!");
				}

				// 开始合成

				// 扣除游戏币
				me.addAndUpdateSmall_money(-1 * modifyPrice);

				// 随机生成等级
				int level;
				if (MmochatUtil.isInPercent(99)) {
					level = 1;
				} else if (MmochatUtil.isInPercent(99)) {
					level = 2;
				} else {
					level = 3;
				}
				targetObj.setLevelLimit(MmochatConstant.pkStoneInitLevelLimit);
				targetObj.setPropLevel(level);

				// 随机生成基础类型
				MmochatEquipAttributeType baseAttrType = MmochatPkMachineService
						.getPkStoneRandBaseAttr();
				MmochatEquipAttribute attr = new MmochatEquipAttribute();
				attr.setType(baseAttrType);
				attr.setValue(MmochatPkMachineService
						.getPkStoneBaseAttrValueByLevel(baseAttrType, targetObj
								.getPropLevel()));
				targetObj.setPkStoneBaseAttr(attr);

				// 随机生成技能
				MmochatEquipAttributeType randAttrType = MmochatPkMachineService
						.getPkStoneRandAttr();
				MmochatEquipAttribute attr1 = new MmochatEquipAttribute();
				attr1.setType(randAttrType);
				attr1.setValue(MmochatPkMachineService
						.getPkStoneSkillValueByLevel(randAttrType, targetObj
								.getPropLevel()));
				targetObj.setPkStoneAttr(attr1);

				// 保存数据库
				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addAndUpdateSmall_money(modifyPrice);
					targetObj.setPkStoneAttr(null);
					targetObj.setLevelLimit(1);
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
				}
				MmochatStatisticsService.addSmallMoneyCost(
						MmochatSmallMoneyCostType.武魂石鉴定, -1 * modifyPrice);
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.addGrid(propGrid);
				MmochatUtil.sendCommonPack(me, pack);

				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "恭喜!武魂石技能鉴定成功。");
			}
			default:
				break;
			}

			me.unLockState();
			return new Mmochat_14_12S(req.getHallState(), "此功能暂未开放!");
		} catch (Exception e) {
			e.printStackTrace();
			return new Mmochat_14_12S(req.getHallState(), "服务器忙,请稍候再试!");
		}
	}

	// 14.13 无混沌的高改
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_14_13(SkymobiHandler handler,
			Mmochat_14_13C req) {
		try {
			MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
					.getRoleId());
			if (me == null) {
				return new Mmochat_14_12S(req.getHallState(), "服务器忙,请稍候再试!");
			}

			if (!me.lockState(MmochatRoleStateType.改造装备时)) {
				return null;
			}

			List<Integer> gridIds = req.getGridIds();
			List<MmochatPackageGrid> objs = new ArrayList<MmochatPackageGrid>();
			for (Integer gridId : gridIds) {
				MmochatPackageGrid grid = me.getMyPackage().get(gridId);
				if (grid == null || !grid.hasObj()) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(), "提交的物品不存在!");
				}
				objs.add(grid);
			}

			// 装备+2块改造石+混沌石
			int modifyPrice = MmochatConstant.getModifyEquipPrice();
			if (me.getSmall_money() < modifyPrice) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "改造需要"
						+ MmochatUtil.getColorMoney(modifyPrice) + "文钱，您的金钱不够!");
			}
			List<MmochatPackageGrid> equipList = new ArrayList<MmochatPackageGrid>();
			List<MmochatPackageGrid> prop_modify = new ArrayList<MmochatPackageGrid>();
			List<MmochatPackageGrid> prop_superModify = new ArrayList<MmochatPackageGrid>();
			List<MmochatPackageGrid> prop_superModifyBall = new ArrayList<MmochatPackageGrid>();
			List<MmochatPackageGrid> prop_noDestroy = new ArrayList<MmochatPackageGrid>();
			List<MmochatPackageGrid> other = new ArrayList<MmochatPackageGrid>();
			for (MmochatPackageGrid grid : objs) {
				MmochatCommonObject obj = grid.getObject();
				if (obj == null) {
					continue;
				}
				if (obj.getObjectType() == MmochatObjectType.装备) {
					equipList.add(grid);
				} else if (obj.getObjectType() == MmochatObjectType.道具) {
					if (obj.getPropType() == MmochatPropType.改造石) {
						prop_modify.add(grid);
					} else if (obj.getPropType() == MmochatPropType.超级改造石) {
						prop_superModify.add(grid);
					} else if (obj.getPropType() == MmochatPropType.改造灵珠) {
						prop_superModifyBall.add(grid);
					} else if (obj.getPropType() == MmochatPropType.混沌石) {
						prop_noDestroy.add(grid);
					} else {
						other.add(grid);
					}
				} else {
					other.add(grid);
				}
			}
			// 检查是否有其它物品
			if (other.size() > 0) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "提交的物品不正确!");
			}
			// 检查装备
			if (equipList.size() == 0) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
			}
			if (equipList.size() > 1) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "只能提交一件要改造的装备!");
			}
			if ((prop_modify.size() > 0 && prop_superModify.size() > 0)
					|| (prop_superModifyBall.size() > 0 && prop_modify.size() > 0)
					|| (prop_superModifyBall.size() > 0 && prop_superModify
							.size() > 0)) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(),
						"改造石、超级改造石、改造灵珠三类改造道具只能提交其中一种!不能混合提交。");
			}
			MmochatPackageGrid equipGrid = equipList.get(0);
			if (equipGrid == null) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
			}
			MmochatCommonObject equip = equipGrid.getObject();
			if (equip == null) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "请提交要改造的装备!");
			}
			if (equip.getEquipType() != MmochatEquipType.头盔
					&& equip.getEquipType() != MmochatEquipType.武器
					&& equip.getEquipType() != MmochatEquipType.衣服
					&& equip.getEquipType() != MmochatEquipType.鞋子) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "此物品无法改造!");
			}
			// 检查改造石:数量
			if (equip.getEquipQuality() == MmochatEquipQualityType.白装) {
				if (prop_modify.size() > 0) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"白装备改造不需要改造石!");
				}
			} else {
				int num = 0, num1 = 0, num2 = 0;
				for (MmochatPackageGrid grid : prop_modify) {
					if (grid.getObject() != null) {
						num += grid.getObject().getOverlapNum();
					}
				}
				for (MmochatPackageGrid grid : prop_superModify) {
					if (grid.getObject() != null) {
						num1 += grid.getObject().getOverlapNum();
					}
				}
				for (MmochatPackageGrid grid : prop_superModifyBall) {
					if (grid.getObject() != null) {
						num2 += grid.getObject().getOverlapNum();
					}
				}
				if (num < 2 && num1 < 2 && num2 < 2) {
					me.unLockState();
					return new Mmochat_14_12S(req.getHallState(),
							"请提交2块改造石，或2块超级改造石，或2块改造灵珠!");
				}
			}

			// 改造上限
			int equipModifyLevel = equip.getEquipModifyLevel();
			if (equipModifyLevel >= MmochatConstant.maxEquipModifyLevel) {
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "此装备已达改造上限,无法改造!");
			}

			// 6改7以上时，混沌石判断
			boolean destroy = true;
			if (equipModifyLevel >= 6) {
				if (prop_noDestroy.size() > 0) {
					MmochatPackageGrid grid = prop_noDestroy.get(0);
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null) {
							if (obj.getOverlapNum() > 0) {
								destroy = false;
							}
						}
					}
				}
			}

			// 开始改造
			// 备份
			Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyPackage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());

			// 扣除游戏币
			me.addAndUpdateSmall_money(-1 * modifyPrice);

			// 扣除道具
			List<MmochatPackageGrid> gridNeedUpdate = new ArrayList<MmochatPackageGrid>();
			int needNum = 2;
			boolean useSuperModify = false; // 使用超级改造石增加成功机率
			boolean useModifyBall = false;// 使用改造灵珠

			// 改造石
			if (prop_modify.size() > 0) {
				for (MmochatPackageGrid grid : prop_modify) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
			} else if (prop_superModify.size() > 0) {
				useSuperModify = true;
				for (MmochatPackageGrid grid : prop_superModify) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
			} else if (prop_superModifyBall.size() > 0) {
				useModifyBall = true;
				for (MmochatPackageGrid grid : prop_superModifyBall) {
					MmochatCommonObject obj = grid.getObject();
					if (obj != null) {
						if (obj.getOverlapNum() > needNum) {
							obj.delOverlapNum(needNum);
							needNum = 0;
						} else {
							grid.setObject(null);
							needNum -= obj.getOverlapNum();
							obj.setOverlapNum(0);
						}
						gridNeedUpdate.add(grid);
						if (needNum <= 0) {
							break;
						}
					}
				}
			}
			// 混沌石，6改7以前，不消耗混沌
			if (equipModifyLevel >= 6) {
				if (prop_noDestroy.size() > 0) {
					MmochatPackageGrid grid = prop_noDestroy.get(0);
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null) {
							if (obj.getOverlapNum() > 1) {
								obj.delOverlapNum(1);
								gridNeedUpdate.add(grid);
							} else if (obj.getOverlapNum() == 1) {
								grid.setObject(null);
								gridNeedUpdate.add(grid);
							}
						}
					}
				}
			}

			// 成功率
			double rate = modifyRate[equipModifyLevel];
			if (useSuperModify) {
				rate = rate + 50;
			} else if (useModifyBall) {
				rate = 50;
			}

			String userMsg;
			String systemMsg = null;
			if (equipModifyLevel <= 5) {
				// 改6前都不爆
				if (MmochatUtil.isInPercent(rate)) {
					// 改造成功
					equipModifyLevel = Math.min(
							MmochatConstant.maxEquipModifyLevel,
							equipModifyLevel + 1);
					equip.setEquipModifyLevel(equipModifyLevel);
					userMsg = MmochatUtil.wrapColor("恭喜您，改造成功了！装备的改造等级提升到"
							+ equip.getEquipModifyLevel() + "级。", Color.green);
				} else {
					// 改造失败
					if (!useModifyBall) {
						equipModifyLevel = Math.max(0, equipModifyLevel - 1);
					}
					equip.setEquipModifyLevel(equipModifyLevel);
					userMsg = MmochatUtil.wrapColor("真遗憾，改造失败了！当前改造等级为"
							+ equip.getEquipModifyLevel() + "级。", Color.red);
				}
			} else {
				// 改7及以上
				if (MmochatUtil.isInPercent(rate)) {
					// 改造成功
					equipModifyLevel = Math.min(
							MmochatConstant.maxEquipModifyLevel,
							equipModifyLevel + 1);
					equip.setEquipModifyLevel(equipModifyLevel);
					userMsg = MmochatUtil.wrapColor("恭喜您，改造成功了！装备的改造等级提升到"
							+ equip.getEquipModifyLevel() + "级。", Color.green);
					if (equip.getEquipModifyLevel() >= 15) {
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.green)
								+ MmochatUtil.wrapColor("将"
										+ MmochatUtil.wrapColor(
												equip.getName(), equip
														.getEquipQuality()
														.getColor()) + "改"
										+ equip.getEquipModifyLevel()
										+ "了,难道这就是传说中的狗屎运?", Color.yellow);
					}
				} else {
					// 改造失败
					if (!destroy) {
						if (!useModifyBall) {
							equipModifyLevel = Math
									.max(0, equipModifyLevel - 1);
						}
						equip.setEquipModifyLevel(equipModifyLevel);
						userMsg = MmochatUtil
								.wrapColor("真遗憾，改造失败了！当前改造等级为"
										+ equip.getEquipModifyLevel() + "级。",
										Color.red);
					} else {
						// 装备消失
						equipGrid.setObject(null);
						userMsg = MmochatUtil.wrapColor(
								"真遗憾，改造失败了!当前装备消失。(改7以上，未使用混沌石，失败时装备消失)",
								Color.red);
					}
				}
			}
			gridNeedUpdate.add(equipGrid);

			try {
				MmochatDao.updateMyPackage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addAndUpdateSmall_money(modifyPrice);
				me.setMyPackage(packageBak);
				me.unLockState();
				return new Mmochat_14_12S(req.getHallState(), "数据库忙，请稍候再试!");
			}
			MmochatStatisticsService.addSmallMoneyCost(
					MmochatSmallMoneyCostType.装备改造, -1 * modifyPrice);
			if (systemMsg != null) {
				MmochatChatService.sendSystemMsg(systemMsg);
			}

			Mmochat_5_1S pack = new Mmochat_5_1S();
			pack.setGrids(gridNeedUpdate);
			MmochatUtil.sendCommonPack(me, pack);
			me.unLockState();
			return new Mmochat_14_12S(req.getHallState(), userMsg);
		} catch (Exception e) {
			e.printStackTrace();
			return new Mmochat_14_12S(req.getHallState(), "服务器忙,请稍候再试!");
		}
	}

	// 装备升级：从V0升级到V20111108
	public static MmochatCommonObject updateEquipToV20111108(
			MmochatCommonObject equip) {
		if (equip == null) {
			return null;
		}
		if (equip.getObjectType() != MmochatObjectType.装备) {
			return equip;
		}
		if (equip.getEquipVersion() == null
				|| equip.getEquipVersion() != MmochatEquipVersion.V20111108) {
			try {
				// 装备基础属性
				equip.getEquipBaseAttr().clear();
				List<MmochatEquipAttributeType> baseAttrType = getEquipAttributeTypes(
						equip.getEquipType(),
						MmochatEquipAttributeQualityType.基础属性);
				for (MmochatEquipAttributeType attrType : baseAttrType) {
					MmochatEquipAttribute attr = new MmochatEquipAttribute();
					attr.setType(attrType);
					attr.setValue(getEquipBaseAttrValue(equip.getEquipType(),
							equip.getEquipLevelNeed(), attrType));
					equip.getEquipBaseAttr().add(attr);
				}
				// 装备改造数值
				equip.setEquipModifyLevel(equip.getEquipModifyLevel());

				// 设置装备版本号
				equip.setEquipVersion(MmochatEquipVersion.V20111108);
			} catch (Exception e) {
				e.printStackTrace();
				return equip;
			}
		}
		return equip;
	}
}
